diff --git a/include/llvm/MC/MCELFObjectWriter.h b/include/llvm/MC/MCELFObjectWriter.h index 9ff7011df1d..2d441fdeee2 100644 --- a/include/llvm/MC/MCELFObjectWriter.h +++ b/include/llvm/MC/MCELFObjectWriter.h @@ -53,13 +53,14 @@ struct ELFRelocationEntry { class MCELFObjectTargetWriter : public MCObjectTargetWriter { const uint8_t OSABI; + const uint8_t ABIVersion; const uint16_t EMachine; const unsigned HasRelocationAddend : 1; const unsigned Is64Bit : 1; protected: MCELFObjectTargetWriter(bool Is64Bit_, uint8_t OSABI_, uint16_t EMachine_, - bool HasRelocationAddend); + bool HasRelocationAddend_, uint8_t ABIVersion_ = 0); public: virtual ~MCELFObjectTargetWriter() = default; @@ -97,6 +98,7 @@ public: /// \name Accessors /// @{ uint8_t getOSABI() const { return OSABI; } + uint8_t getABIVersion() const { return ABIVersion; } uint16_t getEMachine() const { return EMachine; } bool hasRelocationAddend() const { return HasRelocationAddend; } bool is64Bit() const { return Is64Bit; } diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 9cae28128c9..aec2bdeded3 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -425,7 +425,8 @@ void ELFWriter::writeHeader(const MCAssembler &Asm) { W.OS << char(ELF::EV_CURRENT); // e_ident[EI_VERSION] // e_ident[EI_OSABI] W.OS << char(OWriter.TargetObjectWriter->getOSABI()); - W.OS << char(0); // e_ident[EI_ABIVERSION] + // e_ident[EI_ABIVERSION] + W.OS << char(OWriter.TargetObjectWriter->getABIVersion()); W.OS.write_zeros(ELF::EI_NIDENT - ELF::EI_PAD); diff --git a/lib/MC/MCELFObjectTargetWriter.cpp b/lib/MC/MCELFObjectTargetWriter.cpp index 9ad7f8c123a..a81eab9ca29 100644 --- a/lib/MC/MCELFObjectTargetWriter.cpp +++ b/lib/MC/MCELFObjectTargetWriter.cpp @@ -12,8 +12,9 @@ using namespace llvm; MCELFObjectTargetWriter::MCELFObjectTargetWriter(bool Is64Bit_, uint8_t OSABI_, uint16_t EMachine_, - bool HasRelocationAddend_) - : OSABI(OSABI_), EMachine(EMachine_), + bool HasRelocationAddend_, + uint8_t ABIVersion_) + : OSABI(OSABI_), ABIVersion(ABIVersion_), EMachine(EMachine_), HasRelocationAddend(HasRelocationAddend_), Is64Bit(Is64Bit_) {} bool MCELFObjectTargetWriter::needsRelocateWithSymbol(const MCSymbol &Sym,