Index: test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml =================================================================== --- test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml +++ test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml @@ -5,6 +5,7 @@ # CHECK-NEXT: Type: SHT_RELA # CHECK-NEXT: Link: .symtab # CHECK-NEXT: AddressAlign: 0x0000000000000008 +# CHECK-NEXT: EntSize: 0x0000000000000018 # CHECK-NEXT: Info: .text # CHECK-NEXT: Relocations: # CHECK-NEXT: - Offset: 0x0000000000000000 Index: test/Object/Mips/abi-flags.yaml =================================================================== --- test/Object/Mips/abi-flags.yaml +++ test/Object/Mips/abi-flags.yaml @@ -25,6 +25,7 @@ # YAML-NEXT: - Name: .MIPS.abiflags # YAML-NEXT: Type: SHT_MIPS_ABIFLAGS # YAML-NEXT: AddressAlign: 0x0000000000000008 +# YAML-NEXT: EntSize: 0x0000000000000018 # YAML-NEXT: ISA: MIPS64 # YAML-NEXT: ISARevision: 0x05 # YAML-NEXT: ISAExtension: EXT_OCTEON3 Index: test/Object/obj2yaml-invalid-reloc.test =================================================================== --- test/Object/obj2yaml-invalid-reloc.test +++ test/Object/obj2yaml-invalid-reloc.test @@ -17,6 +17,7 @@ CHECK-NEXT: Type: SHT_RELA CHECK-NEXT: Link: .symtab CHECK-NEXT: AddressAlign: 0x0000000000000008 +CHECK-NEXT: EntSize: 0x0000000000000018 CHECK-NEXT: Info: .text CHECK-NEXT: Relocations: CHECK-NEXT: - Offset: 0x0000000000000000 Index: test/Object/obj2yaml.test =================================================================== --- test/Object/obj2yaml.test +++ test/Object/obj2yaml.test @@ -364,6 +364,7 @@ ELF-MIPSEL-NEXT: Type: SHT_REL ELF-MIPSEL-NEXT: Link: .symtab ELF-MIPSEL-NEXT: AddressAlign: 0x0000000000000004 +ELF-MIPSEL-NEXT: EntSize: 0x0000000000000008 ELF-MIPSEL-NEXT: Info: .text ELF-MIPSEL-NEXT: Relocations: ELF-MIPSEL-NEXT: - Offset: 0x0000000000000000 @@ -402,6 +403,7 @@ ELF-MIPSEL-NEXT: Type: SHT_PROGBITS ELF-MIPSEL-NEXT: Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ] ELF-MIPSEL-NEXT: AddressAlign: 0x0000000000000001 +ELF-MIPSEL-NEXT: EntSize: 0x0000000000000001 ELF-MIPSEL-NEXT: Content: 48656C6C6F20576F726C640A00 ELF-MIPSEL-NEXT: - Name: .reginfo ELF-MIPSEL-NEXT: Type: SHT_MIPS_REGINFO @@ -481,6 +483,7 @@ ELF-MIPS64EL-NEXT: Type: SHT_RELA ELF-MIPS64EL-NEXT: Link: .symtab ELF-MIPS64EL-NEXT: AddressAlign: 0x0000000000000008 +ELF-MIPS64EL-NEXT: EntSize: 0x0000000000000018 ELF-MIPS64EL-NEXT: Info: .data ELF-MIPS64EL-NEXT: Relocations: ELF-MIPS64EL-NEXT: - Offset: 0 @@ -494,6 +497,7 @@ ELF-MIPS64EL-NEXT: Type: SHT_MIPS_OPTIONS ELF-MIPS64EL-NEXT: Flags: [ SHF_ALLOC, SHF_MIPS_NOSTRIP ] ELF-MIPS64EL-NEXT: AddressAlign: 0x0000000000000008 +ELF-MIPS64EL-NEXT: EntSize: 0x0000000000000001 ELF-MIPS64EL-NEXT: Content: '01280000000000000000000000000000000000000000000000000000000000000000000000000000' ELF-MIPS64EL-NEXT: - Name: .pdr ELF-MIPS64EL-NEXT: Type: SHT_PROGBITS @@ -549,6 +553,7 @@ ELF-X86-64-NEXT: Address: 0x0000000000000038 ELF-X86-64-NEXT: Link: .symtab ELF-X86-64-NEXT: AddressAlign: 0x0000000000000008 +ELF-X86-64-NEXT: EntSize: 0x0000000000000018 ELF-X86-64-NEXT: Info: .text ELF-X86-64-NEXT: Relocations: ELF-X86-64-NEXT: - Offset: 0x000000000000000D Index: test/tools/obj2yaml/elf-entsize.yaml =================================================================== --- /dev/null +++ test/tools/obj2yaml/elf-entsize.yaml @@ -0,0 +1,21 @@ +# RUN: yaml2obj %s -o %t +# RUN: obj2yaml %t | FileCheck %s + +## Check obj2yaml is able to dump sh_entsize field of a section. + +# CHECK: - Name: .rodata.cst4 +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags: [ SHF_ALLOC, SHF_MERGE ] +# CHECK-NEXT: EntSize: 0x0000000000000004 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .rodata.cst4 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_MERGE ] + EntSize: 0x0000000000000004 Index: tools/obj2yaml/elf2yaml.cpp =================================================================== --- tools/obj2yaml/elf2yaml.cpp +++ tools/obj2yaml/elf2yaml.cpp @@ -317,6 +317,8 @@ S.Flags = Shdr->sh_flags; S.Address = Shdr->sh_addr; S.AddressAlign = Shdr->sh_addralign; + if (Shdr->sh_entsize) + S.EntSize = (llvm::yaml::Hex64)Shdr->sh_entsize; auto NameOrErr = getUniquedSectionName(Shdr); if (!NameOrErr)