llvm.org GIT mirror llvm / b728126
Revert "Revert r363377: [yaml2obj] - Allow setting custom section types for implicit sections." LLD test case will be fixed in a following commit. Original commit message: [yaml2obj] - Allow setting custom section types for implicit sections. We were hardcoding the final section type for sections that are usually implicit. The patch fixes that. This also fixes a few issues in existent test cases and removes one precompiled object. Differential revision: https://reviews.llvm.org/D63267 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363401 91177308-0d34-0410-b5e6-96231b3b80d8 George Rimar a month ago
8 changed file(s) with 113 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
test/tools/llvm-readobj/Inputs/wrong-shstrtab-type.elf-x86-64 less more
Binary diff not shown
None ## wrong-shstrtab-type.elf-x86-64 contains .shstrtab section which has SHT_PROGBITS type.
1 ## Check we do not fail to dump the section headers in this case.
0 ## Check we do not fail to dump the section headers when
1 ## a .shstrtab section does not have a SHT_STRTAB type.
22
3 # RUN: llvm-readobj -S %p/Inputs/wrong-shstrtab-type.elf-x86-64 | FileCheck %s --check-prefix LLVM
4 # RUN: llvm-readelf -S %p/Inputs/wrong-shstrtab-type.elf-x86-64 | FileCheck %s --check-prefix GNU
3 # RUN: yaml2obj %s -o %t1
4 # RUN: llvm-readobj -S %t1 | FileCheck %s --check-prefix LLVM
5 # RUN: llvm-readelf -S %t1 | FileCheck %s --check-prefix GNU
56
67 # LLVM: Name: .shstrtab
78 # LLVM-NEXT: Type: SHT_PROGBITS
89
910 # GNU: [Nr] Name Type
10 # GNU: [ 3] .shstrtab PROGBITS
11 # GNU: [ 1] .shstrtab PROGBITS
12
13 --- !ELF
14 FileHeader:
15 Class: ELFCLASS64
16 Data: ELFDATA2LSB
17 Type: ET_DYN
18 Machine: EM_X86_64
19 Sections:
20 - Name: .shstrtab
21 Type: SHT_PROGBITS
2323
2424 --- !ELF
2525 FileHeader:
26 Class: ELFCLASS64
27 Data: ELFDATA2LSB
28 Type: ET_REL
29 Machine: EM_X86_64
26 Class: ELFCLASS64
27 Data: ELFDATA2LSB
28 Type: ET_REL
29 Machine: EM_X86_64
3030 Sections:
31 - Name: .symtab
32 Info: 42
33 Type: SHT_SYMTAB
34 - Name: .dynsym
35 Info: 26
36 Type: SHT_SYMTAB
31 - Name: .symtab
32 Info: 42
33 Type: SHT_SYMTAB
34 - Name: .dynsym
35 Info: 26
36 Type: SHT_DYNSYM
3737 Symbols:
3838 - Name: foo
3939 Binding: STB_GLOBAL
11 # RUN: yaml2obj %s -o %t
22 # RUN: llvm-readobj --sections %t | FileCheck %s
33
4 ## TODO: the output is still SHT_SYMTAB because we do not yet
5 ## support changing it.
64 # CHECK: Name: .symtab
7 # CHECK-NEXT: Type: SHT_SYMTAB
5 # CHECK-NEXT: Type: SHT_DYNAMIC
86
97 --- !ELF
10 FileHeader:
11 Class: ELFCLASS64
12 Data: ELFDATA2LSB
13 Type: ET_REL
14 Machine: EM_X86_64
15 Sections:
16 - Name: .symtab
17 Type: SHT_DYNAMIC
8 FileHeader:
9 Class: ELFCLASS64
10 Data: ELFDATA2LSB
11 Type: ET_REL
12 Machine: EM_X86_64
13 Sections:
14 - Name: .symtab
15 Type: SHT_DYNAMIC
1816 Symbols:
1917 - Name: foo
2018 Binding: STB_GLOBAL
1818 Machine: EM_X86_64
1919 Sections:
2020 - Name: .dynsym
21 Type: SHT_SYMTAB
21 Type: SHT_DYNSYM
0 ## Here we check the types set for implicit sections
1 ## in different cases.
2
3 ## Check the types set by default in case sections were implicitly
4 ## added and not described in the YAML.
5
6 # RUN: yaml2obj --docnum=1 %s -o %t1
7 # RUN: llvm-readobj -S %t1 | FileCheck %s --check-prefix=CASE1
8
9 # CASE1: Name: .symtab
10 # CASE1-NEXT: Type: SHT_SYMTAB
11 # CASE1: Name: .strtab
12 # CASE1-NEXT: Type: SHT_STRTAB
13 # CASE1: Name: .shstrtab
14 # CASE1-NEXT: Type: SHT_STRTAB
15 # CASE1: Name: .dynsym
16 # CASE1-NEXT: Type: SHT_DYNSYM
17 # CASE1: Name: .dynstr
18 # CASE1-NEXT: Type: SHT_STRTAB
19
20 --- !ELF
21 FileHeader:
22 Class: ELFCLASS64
23 Data: ELFDATA2LSB
24 Type: ET_DYN
25 Machine: EM_X86_64
26 ## Needed to force the creation of the .dynsym and .dynstr.
27 DynamicSymbols:
28 - Name: foo
29 - Binding: STB_GLOBAL
30
31 ## Check we can set any arbitrary types when describing sections
32 ## that are usually implicit.
33
34 # RUN: yaml2obj --docnum=2 %s -o %t2
35 # RUN: llvm-readobj -S %t2 | FileCheck %s --check-prefix=CASE2
36
37 # CASE2: Name: .symtab
38 # CASE2-NEXT: Type: SHT_DYNAMIC
39 # CASE2: Name: .strtab
40 # CASE2-NEXT: Type: SHT_RELA
41 # CASE2: Name: .shstrtab
42 # CASE2-NEXT: Type: SHT_PROGBITS
43 # CASE2: Name: .dynsym
44 # CASE2-NEXT: Type: SHT_NOTE
45 # CASE2: Name: .dynstr
46 # CASE2-NEXT: Type: SHT_NOBITS
47
48 --- !ELF
49 FileHeader:
50 Class: ELFCLASS64
51 Data: ELFDATA2LSB
52 Type: ET_DYN
53 Machine: EM_X86_64
54 Sections:
55 - Name: .symtab
56 Type: SHT_DYNAMIC
57 - Name: .strtab
58 Type: SHT_RELA
59 - Name: .shstrtab
60 Type: SHT_PROGBITS
61 - Name: .dynsym
62 Type: SHT_NOTE
63 - Name: .dynstr
64 Type: SHT_NOBITS
65 ## Needed to set the proper content size for .symtab, so
66 ## that llvm-readobj can dump this section.
67 Symbols:
68 - Name: foo
2626 - Name: .symtab
2727 Type: SHT_SYMTAB
2828 - Name: .dynsym
29 Type: SHT_SYMTAB
29 Type: SHT_DYNSYM
3030
3131 ## Check we can set arbitrary flags for .symtab/.dynsym.
3232
5656 Type: SHT_SYMTAB
5757 Flags: [ SHF_ALLOC, SHF_STRINGS ]
5858 - Name: .dynsym
59 Type: SHT_SYMTAB
59 Type: SHT_DYNSYM
6060 Flags: [ SHF_STRINGS ]
6161
6262 ## Check no flags are set by default for .symtab when it is not
402402
403403 zero(SHeader);
404404 SHeader.sh_name = DotShStrtab.getOffset(IsStatic ? ".symtab" : ".dynsym");
405 SHeader.sh_type = IsStatic ? ELF::SHT_SYMTAB : ELF::SHT_DYNSYM;
405
406 if (YAMLSec)
407 SHeader.sh_type = YAMLSec->Type;
408 else
409 SHeader.sh_type = IsStatic ? ELF::SHT_SYMTAB : ELF::SHT_DYNSYM;
406410
407411 if (RawSec && !RawSec->Link.empty()) {
408412 // If the Link field is explicitly defined in the document,
466470 ELFYAML::Section *YAMLSec) {
467471 zero(SHeader);
468472 SHeader.sh_name = DotShStrtab.getOffset(Name);
469 SHeader.sh_type = ELF::SHT_STRTAB;
473 SHeader.sh_type = YAMLSec ? YAMLSec->Type : ELF::SHT_STRTAB;
470474 SHeader.sh_addralign = YAMLSec ? (uint64_t)YAMLSec->AddressAlign : 1;
471475
472476 ELFYAML::RawContentSection *RawSec =