diff options
author | Roman Divacky <rdivacky@freebsd.org> | 2010-09-09 17:57:50 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@freebsd.org> | 2010-09-09 17:57:50 +0000 |
commit | 5baf79edc067a4b17d024cc10324ac88c17e3e43 (patch) | |
tree | d2af961bedf189afa8623a0e47ceaecce71d54b6 /lib | |
parent | 9ae4ca611b7fb082e8d5c3dc3870882a2ec45fe9 (diff) | |
download | external_llvm-5baf79edc067a4b17d024cc10324ac88c17e3e43.zip external_llvm-5baf79edc067a4b17d024cc10324ac88c17e3e43.tar.gz external_llvm-5baf79edc067a4b17d024cc10324ac88c17e3e43.tar.bz2 |
Make ELF OS ABI dependent on the OS from target triple.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113508 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MC/ELFObjectWriter.cpp | 17 | ||||
-rw-r--r-- | lib/Target/X86/X86AsmBackend.cpp | 21 |
2 files changed, 25 insertions, 13 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 5713f47..b12491e 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -107,6 +107,8 @@ namespace { bool HasRelocationAddend; + Triple::OSType OSType; + // This holds the symbol table index of the last local symbol. unsigned LastLocalSymbolIndex; // This holds the .strtab section index. @@ -116,9 +118,10 @@ namespace { public: ELFObjectWriterImpl(ELFObjectWriter *_Writer, bool _Is64Bit, - bool _HasRelAddend) + bool _HasRelAddend, Triple::OSType _OSType) : Writer(_Writer), OS(Writer->getStream()), - Is64Bit(_Is64Bit), HasRelocationAddend(_HasRelAddend) { + Is64Bit(_Is64Bit), HasRelocationAddend(_HasRelAddend), + OSType(_OSType) { } void Write8(uint8_t Value) { Writer->Write8(Value); } @@ -270,7 +273,12 @@ void ELFObjectWriterImpl::WriteHeader(uint64_t SectionDataSize, Write8(Writer->isLittleEndian() ? ELF::ELFDATA2LSB : ELF::ELFDATA2MSB); Write8(ELF::EV_CURRENT); // e_ident[EI_VERSION] - Write8(ELF::ELFOSABI_LINUX); // e_ident[EI_OSABI] + // e_ident[EI_OSABI] + switch (OSType) { + case Triple::FreeBSD: Write8(ELF::ELFOSABI_FREEBSD); break; + case Triple::Linux: Write8(ELF::ELFOSABI_LINUX); break; + default: Write8(ELF::ELFOSABI_NONE); break; + } Write8(0); // e_ident[EI_ABIVERSION] WriteZeros(ELF::EI_NIDENT - ELF::EI_PAD); @@ -955,11 +963,12 @@ void ELFObjectWriterImpl::WriteObject(const MCAssembler &Asm, ELFObjectWriter::ELFObjectWriter(raw_ostream &OS, bool Is64Bit, + Triple::OSType OSType, bool IsLittleEndian, bool HasRelocationAddend) : MCObjectWriter(OS, IsLittleEndian) { - Impl = new ELFObjectWriterImpl(this, Is64Bit, HasRelocationAddend); + Impl = new ELFObjectWriterImpl(this, Is64Bit, HasRelocationAddend, OSType); } ELFObjectWriter::~ELFObjectWriter() { diff --git a/lib/Target/X86/X86AsmBackend.cpp b/lib/Target/X86/X86AsmBackend.cpp index 69dc967..4b51b69 100644 --- a/lib/Target/X86/X86AsmBackend.cpp +++ b/lib/Target/X86/X86AsmBackend.cpp @@ -186,25 +186,27 @@ bool X86AsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const { namespace { class ELFX86AsmBackend : public X86AsmBackend { public: - ELFX86AsmBackend(const Target &T) - : X86AsmBackend(T) { + Triple::OSType OSType; + ELFX86AsmBackend(const Target &T, Triple::OSType _OSType) + : X86AsmBackend(T), OSType(_OSType) { HasAbsolutizedSet = true; HasScatteredSymbols = true; } bool isVirtualSection(const MCSection &Section) const { const MCSectionELF &SE = static_cast<const MCSectionELF&>(Section); - return SE.getType() == MCSectionELF::SHT_NOBITS;; + return SE.getType() == MCSectionELF::SHT_NOBITS; } }; class ELFX86_32AsmBackend : public ELFX86AsmBackend { public: - ELFX86_32AsmBackend(const Target &T) - : ELFX86AsmBackend(T) {} + ELFX86_32AsmBackend(const Target &T, Triple::OSType OSType) + : ELFX86AsmBackend(T, OSType) {} MCObjectWriter *createObjectWriter(raw_ostream &OS) const { return new ELFObjectWriter(OS, /*Is64Bit=*/false, + OSType, /*IsLittleEndian=*/true, /*HasRelocationAddend=*/false); } @@ -212,11 +214,12 @@ public: class ELFX86_64AsmBackend : public ELFX86AsmBackend { public: - ELFX86_64AsmBackend(const Target &T) - : ELFX86AsmBackend(T) {} + ELFX86_64AsmBackend(const Target &T, Triple::OSType OSType) + : ELFX86AsmBackend(T, OSType) {} MCObjectWriter *createObjectWriter(raw_ostream &OS) const { return new ELFObjectWriter(OS, /*Is64Bit=*/true, + OSType, /*IsLittleEndian=*/true, /*HasRelocationAddend=*/true); } @@ -324,7 +327,7 @@ TargetAsmBackend *llvm::createX86_32AsmBackend(const Target &T, case Triple::Win32: return new WindowsX86AsmBackend(T, false); default: - return new ELFX86_32AsmBackend(T); + return new ELFX86_32AsmBackend(T, Triple(TT).getOS()); } } @@ -338,6 +341,6 @@ TargetAsmBackend *llvm::createX86_64AsmBackend(const Target &T, case Triple::Win32: return new WindowsX86AsmBackend(T, true); default: - return new ELFX86_64AsmBackend(T); + return new ELFX86_64AsmBackend(T, Triple(TT).getOS()); } } |