1 //===-- llvm/MC/MCELFObjectWriter.h - ELF Object Writer ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_MC_MCELFOBJECTWRITER_H
11 #define LLVM_MC_MCELFOBJECTWRITER_H
13 #include "llvm/MC/MCObjectWriter.h"
14 #include "llvm/Support/DataTypes.h"
15 #include "llvm/Support/ELF.h"
18 class MCELFObjectTargetWriter {
20 const uint16_t EMachine;
21 const unsigned HasRelocationAddend : 1;
22 const unsigned Is64Bit : 1;
26 MCELFObjectTargetWriter(bool Is64Bit_, uint8_t OSABI_,
27 uint16_t EMachine_, bool HasRelocationAddend_);
30 static uint8_t getOSABI(Triple::OSType OSType) {
33 return ELF::ELFOSABI_FREEBSD;
35 return ELF::ELFOSABI_LINUX;
37 return ELF::ELFOSABI_NONE;
41 virtual ~MCELFObjectTargetWriter() {}
43 virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
44 bool IsPCRel, bool IsRelocWithSymbol,
45 int64_t Addend) const = 0;
46 virtual unsigned getEFlags() const;
47 virtual const MCSymbol *ExplicitRelSym(const MCAssembler &Asm,
48 const MCValue &Target,
52 virtual void adjustFixupOffset(const MCFixup &Fixup,
53 uint64_t &RelocOffset);
58 uint8_t getOSABI() { return OSABI; }
59 uint16_t getEMachine() { return EMachine; }
60 bool hasRelocationAddend() { return HasRelocationAddend; }
61 bool is64Bit() const { return Is64Bit; }
65 /// \brief Construct a new ELF writer instance.
67 /// \param MOTW - The target specific ELF writer subclass.
68 /// \param OS - The stream to write to.
69 /// \returns The constructed object writer.
70 MCObjectWriter *createELFObjectWriter(MCELFObjectTargetWriter *MOTW,
71 raw_ostream &OS, bool IsLittleEndian);
72 } // End llvm namespace