Index: include/llvm/ObjectYAML/ELFYAML.h =================================================================== --- include/llvm/ObjectYAML/ELFYAML.h +++ include/llvm/ObjectYAML/ELFYAML.h @@ -68,6 +68,7 @@ ELF_ELFCLASS Class; ELF_ELFDATA Data; ELF_ELFOSABI OSABI; + llvm::yaml::Hex8 ABIVersion; ELF_ET Type; ELF_EM Machine; ELF_EF Flags; Index: lib/ObjectYAML/ELFYAML.cpp =================================================================== --- lib/ObjectYAML/ELFYAML.cpp +++ lib/ObjectYAML/ELFYAML.cpp @@ -753,6 +753,7 @@ IO.mapRequired("Class", FileHdr.Class); IO.mapRequired("Data", FileHdr.Data); IO.mapOptional("OSABI", FileHdr.OSABI, ELFYAML::ELF_ELFOSABI(0)); + IO.mapOptional("ABIVersion", FileHdr.ABIVersion, Hex8(0)); IO.mapRequired("Type", FileHdr.Type); IO.mapRequired("Machine", FileHdr.Machine); IO.mapOptional("Flags", FileHdr.Flags, ELFYAML::ELF_EF(0)); Index: test/tools/yaml2obj/elf-abiversion.yaml =================================================================== --- /dev/null +++ test/tools/yaml2obj/elf-abiversion.yaml @@ -0,0 +1,16 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-readobj -file-headers %t | FileCheck %s --check-prefix=FROMYAML +# RUN: obj2yaml %t | FileCheck %s --check-prefix=TOYAML + +## Check we are able to parse/emit the ABI version with yaml2obj/obj2yaml. + +# FROMYAML: ABIVersion: 5 +# TOYAML: ABIVersion: 0x05 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 + ABIVersion: 0x05 Index: tools/obj2yaml/elf2yaml.cpp =================================================================== --- tools/obj2yaml/elf2yaml.cpp +++ tools/obj2yaml/elf2yaml.cpp @@ -114,6 +114,7 @@ Y->Header.Class = ELFYAML::ELF_ELFCLASS(Obj.getHeader()->getFileClass()); Y->Header.Data = ELFYAML::ELF_ELFDATA(Obj.getHeader()->getDataEncoding()); Y->Header.OSABI = Obj.getHeader()->e_ident[ELF::EI_OSABI]; + Y->Header.ABIVersion = Obj.getHeader()->e_ident[ELF::EI_ABIVERSION]; Y->Header.Type = Obj.getHeader()->e_type; Y->Header.Machine = Obj.getHeader()->e_machine; Y->Header.Flags = Obj.getHeader()->e_flags; Index: tools/yaml2obj/yaml2elf.cpp =================================================================== --- tools/yaml2obj/yaml2elf.cpp +++ tools/yaml2obj/yaml2elf.cpp @@ -196,7 +196,7 @@ Header.e_ident[EI_DATA] = IsLittleEndian ? ELFDATA2LSB : ELFDATA2MSB; Header.e_ident[EI_VERSION] = EV_CURRENT; Header.e_ident[EI_OSABI] = Doc.Header.OSABI; - Header.e_ident[EI_ABIVERSION] = 0; + Header.e_ident[EI_ABIVERSION] = Doc.Header.ABIVersion; Header.e_type = Doc.Header.Type; Header.e_machine = Doc.Header.Machine; Header.e_version = EV_CURRENT;