[obj2yaml] - Dump the sh_entsize section field.

I faced with the fact that obj2yaml does not dump the sh_entsize field.
A problem arose when I tried to dump ELF versioning sections.

This is close to what D50235 did, but D50235 did the change for yaml2obj, and now
I had to do the same for obj2yaml.

Differential revision: https://reviews.llvm.org/D57229

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352373 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
George Rimar 2019-01-28 15:05:10 +00:00
parent 7762c30a52
commit d01d94f4c3
6 changed files with 31 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -17,6 +17,7 @@ CHECK-NEXT: - Name: .rela.text
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

View File

@ -364,6 +364,7 @@ ELF-MIPSEL-NEXT: - Name: .rel.text
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: - Name: .rodata.str1.1
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: - Name: .rela.data
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: - Name: .MIPS.options
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: Type: SHT_RELA
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

View File

@ -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

View File

@ -317,6 +317,8 @@ std::error_code ELFDumper<ELFT>::dumpCommonSection(const Elf_Shdr *Shdr,
S.Flags = Shdr->sh_flags;
S.Address = Shdr->sh_addr;
S.AddressAlign = Shdr->sh_addralign;
if (Shdr->sh_entsize)
S.EntSize = static_cast<llvm::yaml::Hex64>(Shdr->sh_entsize);
auto NameOrErr = getUniquedSectionName(Shdr);
if (!NameOrErr)