aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/X86/X86ELFWriter.cpp
blob: 0a3a027f1d4ce302946f1a7a17d61bda9de38f87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//===-- X86ELFWriter.cpp - Emit an ELF file for the X86 backend -----------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements an ELF writer for the X86 backend.  The public interface
// to this file is the createX86ELFObjectWriterPass function.
//
//===----------------------------------------------------------------------===//

#include "X86.h"
#include "X86TargetMachine.h"
#include "llvm/PassManager.h"
#include "llvm/CodeGen/ELFWriter.h"
#include "llvm/Support/Visibility.h"
using namespace llvm;

namespace {
  class VISIBILITY_HIDDEN X86ELFWriter : public ELFWriter {
  public:
    X86ELFWriter(std::ostream &O, X86TargetMachine &TM) : ELFWriter(O, TM) {
      e_machine = 3;   // EM_386
    }
  };
}

/// addX86ELFObjectWriterPass - Returns a pass that outputs the generated code
/// as an ELF object file.
///
void llvm::addX86ELFObjectWriterPass(PassManager &FPM,
                                     std::ostream &O, X86TargetMachine &TM) {
  X86ELFWriter *EW = new X86ELFWriter(O, TM);
  FPM.add(EW);
  FPM.add(createX86CodeEmitterPass(EW->getMachineCodeEmitter()));
}