1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

Move some data to the TargetWriter.

llvm-svn: 122134
This commit is contained in:
Rafael Espindola 2010-12-18 03:27:34 +00:00
parent e06ded7533
commit 9a4bfd7755
6 changed files with 93 additions and 107 deletions

View File

@ -15,11 +15,24 @@
namespace llvm { namespace llvm {
class MCELFObjectTargetWriter { class MCELFObjectTargetWriter {
const Triple::OSType OSType;
const uint16_t EMachine;
const unsigned HasRelocationAddend : 1;
const unsigned Is64Bit : 1;
protected: protected:
MCELFObjectTargetWriter(); MCELFObjectTargetWriter(bool Is64Bit_, Triple::OSType OSType_,
uint16_t EMachine_, bool HasRelocationAddend_);
public: public:
virtual ~MCELFObjectTargetWriter(); virtual ~MCELFObjectTargetWriter();
/// @name Accessors
/// @{
Triple::OSType getOSType() { return OSType; }
uint16_t getEMachine() { return EMachine; }
bool hasRelocationAddend() { return HasRelocationAddend; }
bool is64Bit() { return Is64Bit; }
/// @}
}; };
/// \brief Construct a new ELF writer instance. /// \brief Construct a new ELF writer instance.
@ -28,10 +41,7 @@ public:
/// \param OS - The stream to write to. /// \param OS - The stream to write to.
/// \returns The constructed object writer. /// \returns The constructed object writer.
MCObjectWriter *createELFObjectWriter(MCELFObjectTargetWriter *MOTW, MCObjectWriter *createELFObjectWriter(MCELFObjectTargetWriter *MOTW,
raw_ostream &OS, bool is64Bit, raw_ostream &OS, bool IsLittleEndian);
Triple::OSType OSType, uint16_t EMachine,
bool IsLittleEndian,
bool HasRelocationAddend);
} // End llvm namespace } // End llvm namespace
#endif #endif

View File

@ -175,14 +175,6 @@ namespace {
bool NeedsSymtabShndx; bool NeedsSymtabShndx;
unsigned Is64Bit : 1;
bool HasRelocationAddend;
Triple::OSType OSType;
uint16_t EMachine;
// This holds the symbol table index of the last local symbol. // This holds the symbol table index of the last local symbol.
unsigned LastLocalSymbolIndex; unsigned LastLocalSymbolIndex;
// This holds the .strtab section index. // This holds the .strtab section index.
@ -197,22 +189,23 @@ namespace {
const MCValue &Target, const MCValue &Target,
const MCFragment &F) const; const MCFragment &F) const;
bool is64Bit() const { return TargetObjectWriter->is64Bit(); }
bool hasRelocationAddend() const {
return TargetObjectWriter->hasRelocationAddend();
}
public: public:
ELFObjectWriter(MCELFObjectTargetWriter *MOTW, ELFObjectWriter(MCELFObjectTargetWriter *MOTW,
raw_ostream &_OS, bool _Is64Bit, bool IsLittleEndian, raw_ostream &_OS, bool IsLittleEndian)
uint16_t _EMachine, bool _HasRelAddend,
Triple::OSType _OSType)
: MCObjectWriter(_OS, IsLittleEndian), : MCObjectWriter(_OS, IsLittleEndian),
TargetObjectWriter(MOTW), TargetObjectWriter(MOTW),
NeedsGOT(false), NeedsSymtabShndx(false), NeedsGOT(false), NeedsSymtabShndx(false){
Is64Bit(_Is64Bit), HasRelocationAddend(_HasRelAddend),
OSType(_OSType), EMachine(_EMachine) {
} }
virtual ~ELFObjectWriter(); virtual ~ELFObjectWriter();
void WriteWord(uint64_t W) { void WriteWord(uint64_t W) {
if (Is64Bit) if (is64Bit())
Write64(W); Write64(W);
else else
Write32(W); Write32(W);
@ -382,9 +375,8 @@ namespace {
class X86ELFObjectWriter : public ELFObjectWriter { class X86ELFObjectWriter : public ELFObjectWriter {
public: public:
X86ELFObjectWriter(MCELFObjectTargetWriter *MOTW, X86ELFObjectWriter(MCELFObjectTargetWriter *MOTW,
raw_ostream &_OS, bool _Is64Bit, bool IsLittleEndian, raw_ostream &_OS,
uint16_t _EMachine, bool _HasRelAddend, bool IsLittleEndian);
Triple::OSType _OSType);
virtual ~X86ELFObjectWriter(); virtual ~X86ELFObjectWriter();
protected: protected:
@ -399,9 +391,8 @@ namespace {
class ARMELFObjectWriter : public ELFObjectWriter { class ARMELFObjectWriter : public ELFObjectWriter {
public: public:
ARMELFObjectWriter(MCELFObjectTargetWriter *MOTW, ARMELFObjectWriter(MCELFObjectTargetWriter *MOTW,
raw_ostream &_OS, bool _Is64Bit, bool IsLittleEndian, raw_ostream &_OS,
uint16_t _EMachine, bool _HasRelAddend, bool IsLittleEndian);
Triple::OSType _OSType);
virtual ~ARMELFObjectWriter(); virtual ~ARMELFObjectWriter();
protected: protected:
@ -415,9 +406,8 @@ namespace {
class MBlazeELFObjectWriter : public ELFObjectWriter { class MBlazeELFObjectWriter : public ELFObjectWriter {
public: public:
MBlazeELFObjectWriter(MCELFObjectTargetWriter *MOTW, MBlazeELFObjectWriter(MCELFObjectTargetWriter *MOTW,
raw_ostream &_OS, bool _Is64Bit, bool IsLittleEndian, raw_ostream &_OS,
uint16_t _EMachine, bool _HasRelAddend, bool IsLittleEndian);
Triple::OSType _OSType);
virtual ~MBlazeELFObjectWriter(); virtual ~MBlazeELFObjectWriter();
protected: protected:
@ -446,14 +436,14 @@ void ELFObjectWriter::WriteHeader(uint64_t SectionDataSize,
Write8('L'); // e_ident[EI_MAG2] Write8('L'); // e_ident[EI_MAG2]
Write8('F'); // e_ident[EI_MAG3] Write8('F'); // e_ident[EI_MAG3]
Write8(Is64Bit ? ELF::ELFCLASS64 : ELF::ELFCLASS32); // e_ident[EI_CLASS] Write8(is64Bit() ? ELF::ELFCLASS64 : ELF::ELFCLASS32); // e_ident[EI_CLASS]
// e_ident[EI_DATA] // e_ident[EI_DATA]
Write8(isLittleEndian() ? ELF::ELFDATA2LSB : ELF::ELFDATA2MSB); Write8(isLittleEndian() ? ELF::ELFDATA2LSB : ELF::ELFDATA2MSB);
Write8(ELF::EV_CURRENT); // e_ident[EI_VERSION] Write8(ELF::EV_CURRENT); // e_ident[EI_VERSION]
// e_ident[EI_OSABI] // e_ident[EI_OSABI]
switch (OSType) { switch (TargetObjectWriter->getOSType()) {
case Triple::FreeBSD: Write8(ELF::ELFOSABI_FREEBSD); break; case Triple::FreeBSD: Write8(ELF::ELFOSABI_FREEBSD); break;
case Triple::Linux: Write8(ELF::ELFOSABI_LINUX); break; case Triple::Linux: Write8(ELF::ELFOSABI_LINUX); break;
default: Write8(ELF::ELFOSABI_NONE); break; default: Write8(ELF::ELFOSABI_NONE); break;
@ -464,25 +454,25 @@ void ELFObjectWriter::WriteHeader(uint64_t SectionDataSize,
Write16(ELF::ET_REL); // e_type Write16(ELF::ET_REL); // e_type
Write16(EMachine); // e_machine = target Write16(TargetObjectWriter->getEMachine()); // e_machine = target
Write32(ELF::EV_CURRENT); // e_version Write32(ELF::EV_CURRENT); // e_version
WriteWord(0); // e_entry, no entry point in .o file WriteWord(0); // e_entry, no entry point in .o file
WriteWord(0); // e_phoff, no program header for .o WriteWord(0); // e_phoff, no program header for .o
WriteWord(SectionDataSize + (Is64Bit ? sizeof(ELF::Elf64_Ehdr) : WriteWord(SectionDataSize + (is64Bit() ? sizeof(ELF::Elf64_Ehdr) :
sizeof(ELF::Elf32_Ehdr))); // e_shoff = sec hdr table off in bytes sizeof(ELF::Elf32_Ehdr))); // e_shoff = sec hdr table off in bytes
// FIXME: Make this configurable. // FIXME: Make this configurable.
Write32(0); // e_flags = whatever the target wants Write32(0); // e_flags = whatever the target wants
// e_ehsize = ELF header size // e_ehsize = ELF header size
Write16(Is64Bit ? sizeof(ELF::Elf64_Ehdr) : sizeof(ELF::Elf32_Ehdr)); Write16(is64Bit() ? sizeof(ELF::Elf64_Ehdr) : sizeof(ELF::Elf32_Ehdr));
Write16(0); // e_phentsize = prog header entry size Write16(0); // e_phentsize = prog header entry size
Write16(0); // e_phnum = # prog header entries = 0 Write16(0); // e_phnum = # prog header entries = 0
// e_shentsize = Section header entry size // e_shentsize = Section header entry size
Write16(Is64Bit ? sizeof(ELF::Elf64_Shdr) : sizeof(ELF::Elf32_Shdr)); Write16(is64Bit() ? sizeof(ELF::Elf64_Shdr) : sizeof(ELF::Elf32_Shdr));
// e_shnum = # of section header ents // e_shnum = # of section header ents
if (NumberOfSections >= ELF::SHN_LORESERVE) if (NumberOfSections >= ELF::SHN_LORESERVE)
@ -514,7 +504,7 @@ void ELFObjectWriter::WriteSymbolEntry(MCDataFragment *SymtabF,
uint16_t Index = (shndx >= ELF::SHN_LORESERVE && !Reserved) ? uint16_t Index = (shndx >= ELF::SHN_LORESERVE && !Reserved) ?
uint16_t(ELF::SHN_XINDEX) : shndx; uint16_t(ELF::SHN_XINDEX) : shndx;
if (Is64Bit) { if (is64Bit()) {
String32(*SymtabF, name); // st_name String32(*SymtabF, name); // st_name
String8(*SymtabF, info); // st_info String8(*SymtabF, info); // st_info
String8(*SymtabF, other); // st_other String8(*SymtabF, other); // st_other
@ -791,7 +781,7 @@ void ELFObjectWriter::RecordRelocation(const MCAssembler &Asm,
} }
Addend = Value; Addend = Value;
// Compensate for the addend on i386. // Compensate for the addend on i386.
if (Is64Bit) if (is64Bit())
Value = 0; Value = 0;
} }
@ -802,7 +792,8 @@ void ELFObjectWriter::RecordRelocation(const MCAssembler &Asm,
uint64_t RelocOffset = Layout.getFragmentOffset(Fragment) + uint64_t RelocOffset = Layout.getFragmentOffset(Fragment) +
Fixup.getOffset(); Fixup.getOffset();
if (!HasRelocationAddend) Addend = 0; if (!hasRelocationAddend())
Addend = 0;
ELFRelocationEntry ERE(RelocOffset, Index, Type, RelocSymbol, Addend); ELFRelocationEntry ERE(RelocOffset, Index, Type, RelocSymbol, Addend);
Relocations[Fragment->getParent()].push_back(ERE); Relocations[Fragment->getParent()].push_back(ERE);
} }
@ -1008,22 +999,22 @@ void ELFObjectWriter::WriteRelocation(MCAssembler &Asm, MCAsmLayout &Layout,
static_cast<const MCSectionELF&>(SD.getSection()); static_cast<const MCSectionELF&>(SD.getSection());
const StringRef SectionName = Section.getSectionName(); const StringRef SectionName = Section.getSectionName();
std::string RelaSectionName = HasRelocationAddend ? ".rela" : ".rel"; std::string RelaSectionName = hasRelocationAddend() ? ".rela" : ".rel";
RelaSectionName += SectionName; RelaSectionName += SectionName;
unsigned EntrySize; unsigned EntrySize;
if (HasRelocationAddend) if (hasRelocationAddend())
EntrySize = Is64Bit ? sizeof(ELF::Elf64_Rela) : sizeof(ELF::Elf32_Rela); EntrySize = is64Bit() ? sizeof(ELF::Elf64_Rela) : sizeof(ELF::Elf32_Rela);
else else
EntrySize = Is64Bit ? sizeof(ELF::Elf64_Rel) : sizeof(ELF::Elf32_Rel); EntrySize = is64Bit() ? sizeof(ELF::Elf64_Rel) : sizeof(ELF::Elf32_Rel);
RelaSection = Ctx.getELFSection(RelaSectionName, HasRelocationAddend ? RelaSection = Ctx.getELFSection(RelaSectionName, hasRelocationAddend() ?
ELF::SHT_RELA : ELF::SHT_REL, 0, ELF::SHT_RELA : ELF::SHT_REL, 0,
SectionKind::getReadOnly(), SectionKind::getReadOnly(),
EntrySize, ""); EntrySize, "");
MCSectionData &RelaSD = Asm.getOrCreateSectionData(*RelaSection); MCSectionData &RelaSD = Asm.getOrCreateSectionData(*RelaSection);
RelaSD.setAlignment(Is64Bit ? 8 : 4); RelaSD.setAlignment(is64Bit() ? 8 : 4);
MCDataFragment *F = new MCDataFragment(&RelaSD); MCDataFragment *F = new MCDataFragment(&RelaSD);
@ -1065,14 +1056,14 @@ void ELFObjectWriter::WriteRelocationsFragment(const MCAssembler &Asm,
entry.Index = getSymbolIndexInSymbolTable(Asm, entry.Symbol); entry.Index = getSymbolIndexInSymbolTable(Asm, entry.Symbol);
else else
entry.Index += LocalSymbolData.size(); entry.Index += LocalSymbolData.size();
if (Is64Bit) { if (is64Bit()) {
String64(*F, entry.r_offset); String64(*F, entry.r_offset);
struct ELF::Elf64_Rela ERE64; struct ELF::Elf64_Rela ERE64;
ERE64.setSymbolAndType(entry.Index, entry.Type); ERE64.setSymbolAndType(entry.Index, entry.Type);
String64(*F, ERE64.r_info); String64(*F, ERE64.r_info);
if (HasRelocationAddend) if (hasRelocationAddend())
String64(*F, entry.r_addend); String64(*F, entry.r_addend);
} else { } else {
String32(*F, entry.r_offset); String32(*F, entry.r_offset);
@ -1081,7 +1072,7 @@ void ELFObjectWriter::WriteRelocationsFragment(const MCAssembler &Asm,
ERE32.setSymbolAndType(entry.Index, entry.Type); ERE32.setSymbolAndType(entry.Index, entry.Type);
String32(*F, ERE32.r_info); String32(*F, ERE32.r_info);
if (HasRelocationAddend) if (hasRelocationAddend())
String32(*F, entry.r_addend); String32(*F, entry.r_addend);
} }
} }
@ -1093,7 +1084,7 @@ void ELFObjectWriter::CreateMetadataSections(MCAssembler &Asm,
MCContext &Ctx = Asm.getContext(); MCContext &Ctx = Asm.getContext();
MCDataFragment *F; MCDataFragment *F;
unsigned EntrySize = Is64Bit ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32; unsigned EntrySize = is64Bit() ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32;
// We construct .shstrtab, .symtab and .strtab in this order to match gnu as. // We construct .shstrtab, .symtab and .strtab in this order to match gnu as.
const MCSectionELF *ShstrtabSection = const MCSectionELF *ShstrtabSection =
@ -1108,7 +1099,7 @@ void ELFObjectWriter::CreateMetadataSections(MCAssembler &Asm,
SectionKind::getReadOnly(), SectionKind::getReadOnly(),
EntrySize, ""); EntrySize, "");
MCSectionData &SymtabSD = Asm.getOrCreateSectionData(*SymtabSection); MCSectionData &SymtabSD = Asm.getOrCreateSectionData(*SymtabSection);
SymtabSD.setAlignment(Is64Bit ? 8 : 4); SymtabSD.setAlignment(is64Bit() ? 8 : 4);
SymbolTableIndex = Asm.size(); SymbolTableIndex = Asm.size();
MCSectionData *SymtabShndxSD = NULL; MCSectionData *SymtabShndxSD = NULL;
@ -1393,8 +1384,9 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm,
// Add 1 for the null section. // Add 1 for the null section.
unsigned NumSections = Asm.size() + 1; unsigned NumSections = Asm.size() + 1;
uint64_t NaturalAlignment = Is64Bit ? 8 : 4; uint64_t NaturalAlignment = is64Bit() ? 8 : 4;
uint64_t HeaderSize = Is64Bit ? sizeof(ELF::Elf64_Ehdr) : sizeof(ELF::Elf32_Ehdr); uint64_t HeaderSize = is64Bit() ? sizeof(ELF::Elf64_Ehdr) :
sizeof(ELF::Elf32_Ehdr);
uint64_t FileOff = HeaderSize; uint64_t FileOff = HeaderSize;
std::vector<const MCSectionELF*> Sections; std::vector<const MCSectionELF*> Sections;
@ -1478,23 +1470,15 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm,
MCObjectWriter *llvm::createELFObjectWriter(MCELFObjectTargetWriter *MOTW, MCObjectWriter *llvm::createELFObjectWriter(MCELFObjectTargetWriter *MOTW,
raw_ostream &OS, raw_ostream &OS,
bool Is64Bit, bool IsLittleEndian) {
Triple::OSType OSType, switch (MOTW->getEMachine()) {
uint16_t EMachine,
bool IsLittleEndian,
bool HasRelocationAddend) {
switch (EMachine) {
case ELF::EM_386: case ELF::EM_386:
case ELF::EM_X86_64: case ELF::EM_X86_64:
return new X86ELFObjectWriter(MOTW, OS, Is64Bit, IsLittleEndian, EMachine, return new X86ELFObjectWriter(MOTW, OS, IsLittleEndian); break;
HasRelocationAddend, OSType); break;
case ELF::EM_ARM: case ELF::EM_ARM:
return new ARMELFObjectWriter(MOTW, OS, Is64Bit, IsLittleEndian, EMachine, return new ARMELFObjectWriter(MOTW, OS, IsLittleEndian); break;
HasRelocationAddend, OSType); break;
case ELF::EM_MBLAZE: case ELF::EM_MBLAZE:
return new MBlazeELFObjectWriter(MOTW, OS, Is64Bit, IsLittleEndian, return new MBlazeELFObjectWriter(MOTW, OS, IsLittleEndian); break;
EMachine,
HasRelocationAddend, OSType); break;
default: llvm_unreachable("Unsupported architecture"); break; default: llvm_unreachable("Unsupported architecture"); break;
} }
} }
@ -1504,12 +1488,9 @@ MCObjectWriter *llvm::createELFObjectWriter(MCELFObjectTargetWriter *MOTW,
//===- ARMELFObjectWriter -------------------------------------------===// //===- ARMELFObjectWriter -------------------------------------------===//
ARMELFObjectWriter::ARMELFObjectWriter(MCELFObjectTargetWriter *MOTW, ARMELFObjectWriter::ARMELFObjectWriter(MCELFObjectTargetWriter *MOTW,
raw_ostream &_OS, bool _Is64Bit, raw_ostream &_OS,
bool _IsLittleEndian, bool IsLittleEndian)
uint16_t _EMachine, bool _HasRelocationAddend, : ELFObjectWriter(MOTW, _OS, IsLittleEndian)
Triple::OSType _OSType)
: ELFObjectWriter(MOTW, _OS, _Is64Bit, _IsLittleEndian, _EMachine,
_HasRelocationAddend, _OSType)
{} {}
ARMELFObjectWriter::~ARMELFObjectWriter() ARMELFObjectWriter::~ARMELFObjectWriter()
@ -1592,13 +1573,9 @@ unsigned ARMELFObjectWriter::GetRelocType(const MCValue &Target,
//===- MBlazeELFObjectWriter -------------------------------------------===// //===- MBlazeELFObjectWriter -------------------------------------------===//
MBlazeELFObjectWriter::MBlazeELFObjectWriter(MCELFObjectTargetWriter *MOTW, MBlazeELFObjectWriter::MBlazeELFObjectWriter(MCELFObjectTargetWriter *MOTW,
raw_ostream &_OS, bool _Is64Bit, raw_ostream &_OS,
bool _IsLittleEndian, bool IsLittleEndian)
uint16_t _EMachine, : ELFObjectWriter(MOTW, _OS, IsLittleEndian) {
bool _HasRelocationAddend,
Triple::OSType _OSType)
: ELFObjectWriter(MOTW, _OS, _Is64Bit, _IsLittleEndian, _EMachine,
_HasRelocationAddend, _OSType) {
} }
MBlazeELFObjectWriter::~MBlazeELFObjectWriter() { MBlazeELFObjectWriter::~MBlazeELFObjectWriter() {
@ -1642,12 +1619,9 @@ unsigned MBlazeELFObjectWriter::GetRelocType(const MCValue &Target,
X86ELFObjectWriter::X86ELFObjectWriter(MCELFObjectTargetWriter *MOTW, X86ELFObjectWriter::X86ELFObjectWriter(MCELFObjectTargetWriter *MOTW,
raw_ostream &_OS, bool _Is64Bit, raw_ostream &_OS,
bool _IsLittleEndian, bool IsLittleEndian)
uint16_t _EMachine, bool _HasRelocationAddend, : ELFObjectWriter(MOTW, _OS, IsLittleEndian)
Triple::OSType _OSType)
: ELFObjectWriter(MOTW, _OS, _Is64Bit, _IsLittleEndian, _EMachine,
_HasRelocationAddend, _OSType)
{} {}
X86ELFObjectWriter::~X86ELFObjectWriter() X86ELFObjectWriter::~X86ELFObjectWriter()
@ -1663,7 +1637,7 @@ unsigned X86ELFObjectWriter::GetRelocType(const MCValue &Target,
MCSymbolRefExpr::VariantKind Modifier = Target.isAbsolute() ? MCSymbolRefExpr::VariantKind Modifier = Target.isAbsolute() ?
MCSymbolRefExpr::VK_None : Target.getSymA()->getKind(); MCSymbolRefExpr::VK_None : Target.getSymA()->getKind();
unsigned Type; unsigned Type;
if (Is64Bit) { if (is64Bit()) {
if (IsPCRel) { if (IsPCRel) {
switch (Modifier) { switch (Modifier) {
default: default:

View File

@ -11,7 +11,12 @@
using namespace llvm; using namespace llvm;
MCELFObjectTargetWriter::MCELFObjectTargetWriter() { MCELFObjectTargetWriter::MCELFObjectTargetWriter(bool Is64Bit_,
Triple::OSType OSType_,
uint16_t EMachine_,
bool HasRelocationAddend_)
: OSType(OSType_), EMachine(EMachine_),
HasRelocationAddend(HasRelocationAddend_), Is64Bit(Is64Bit_) {
} }
MCELFObjectTargetWriter::~MCELFObjectTargetWriter() { MCELFObjectTargetWriter::~MCELFObjectTargetWriter() {

View File

@ -39,7 +39,9 @@ public:
class ARMELFObjectWriter : public MCELFObjectTargetWriter { class ARMELFObjectWriter : public MCELFObjectTargetWriter {
public: public:
ARMELFObjectWriter() : MCELFObjectTargetWriter() {} ARMELFObjectWriter(Triple::OSType OSType)
: MCELFObjectTargetWriter(/*Is64Bit*/ false, OSType, ELF::EM_ARM,
/*HasRelocationAddend*/ false) {}
}; };
class ARMAsmBackend : public TargetAsmBackend { class ARMAsmBackend : public TargetAsmBackend {
@ -363,11 +365,8 @@ public:
uint64_t Value) const; uint64_t Value) const;
MCObjectWriter *createObjectWriter(raw_ostream &OS) const { MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return createELFObjectWriter(new ARMELFObjectWriter(), OS, return createELFObjectWriter(new ARMELFObjectWriter(OSType), OS,
/*Is64Bit=*/false, /*IsLittleEndian*/ true);
OSType, ELF::EM_ARM,
/*IsLittleEndian=*/true,
/*HasRelocationAddend=*/false);
} }
}; };

View File

@ -44,7 +44,9 @@ static unsigned getFixupKindSize(unsigned Kind) {
namespace { namespace {
class MBlazeELFObjectWriter : public MCELFObjectTargetWriter { class MBlazeELFObjectWriter : public MCELFObjectTargetWriter {
public: public:
MBlazeELFObjectWriter() : MCELFObjectTargetWriter() {} MBlazeELFObjectWriter(Triple::OSType OSType)
: MCELFObjectTargetWriter(/*is64Bit*/ false, OSType, ELF::EM_MBLAZE,
/*HasRelocationAddend*/ true) {}
}; };
class MBlazeAsmBackend : public TargetAsmBackend { class MBlazeAsmBackend : public TargetAsmBackend {
@ -122,11 +124,8 @@ public:
uint64_t Value) const; uint64_t Value) const;
MCObjectWriter *createObjectWriter(raw_ostream &OS) const { MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return createELFObjectWriter(new MBlazeELFObjectWriter(), return createELFObjectWriter(new MBlazeELFObjectWriter(OSType), OS,
OS,/*Is64Bit=*/false, /*IsLittleEndian*/ false);
OSType, ELF::EM_MBLAZE,
/*IsLittleEndian=*/false,
/*HasRelocationAddend=*/true);
} }
}; };

View File

@ -57,7 +57,9 @@ public:
class X86ELFObjectWriter : public MCELFObjectTargetWriter { class X86ELFObjectWriter : public MCELFObjectTargetWriter {
public: public:
X86ELFObjectWriter() : MCELFObjectTargetWriter() {} X86ELFObjectWriter(bool is64Bit, Triple::OSType OSType, uint16_t EMachine,
bool HasRelocationAddend)
: MCELFObjectTargetWriter(is64Bit, OSType, EMachine, HasRelocationAddend) {}
}; };
class X86AsmBackend : public TargetAsmBackend { class X86AsmBackend : public TargetAsmBackend {
@ -318,11 +320,9 @@ public:
: ELFX86AsmBackend(T, OSType) {} : ELFX86AsmBackend(T, OSType) {}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const { MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return createELFObjectWriter(new X86ELFObjectWriter(), OS, return createELFObjectWriter(new X86ELFObjectWriter(false, OSType,
/*Is64Bit=*/false, ELF::EM_386, false),
OSType, ELF::EM_386, OS, /*IsLittleEndian*/ true);
/*IsLittleEndian=*/true,
/*HasRelocationAddend=*/false);
} }
}; };
@ -332,10 +332,9 @@ public:
: ELFX86AsmBackend(T, OSType) {} : ELFX86AsmBackend(T, OSType) {}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const { MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return createELFObjectWriter(new X86ELFObjectWriter(), OS, /*Is64Bit=*/true, return createELFObjectWriter(new X86ELFObjectWriter(true, OSType,
OSType, ELF::EM_X86_64, ELF::EM_X86_64, true),
/*IsLittleEndian=*/true, OS, /*IsLittleEndian*/ true);
/*HasRelocationAddend=*/true);
} }
}; };