1 //===-- X86ELFWriter.cpp - Emit an ELF file for the X86 backend -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements an ELF writer for the X86 backend. The public interface
11 // to this file is the createX86ELFObjectWriterPass function.
13 //===----------------------------------------------------------------------===//
16 #include "X86TargetMachine.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/CodeGen/ELFWriter.h"
19 #include "llvm/Support/Compiler.h"
23 class VISIBILITY_HIDDEN X86ELFWriter : public ELFWriter {
25 X86ELFWriter(std::ostream &O, X86TargetMachine &TM) : ELFWriter(O, TM) {
26 e_machine = 3; // EM_386
31 /// addX86ELFObjectWriterPass - Returns a pass that outputs the generated code
32 /// as an ELF object file.
34 void llvm::addX86ELFObjectWriterPass(FunctionPassManager &FPM,
35 std::ostream &O, X86TargetMachine &TM) {
36 X86ELFWriter *EW = new X86ELFWriter(O, TM);
38 FPM.add(createX86CodeEmitterPass(TM, EW->getMachineCodeEmitter()));