llvm.org GIT mirror llvm / 642cc2d
Revert r363377: [yaml2obj] - Allow setting custom section types for implicit sections. This reverts commit r363377 because lld's ELF/invalid/undefined-local-symbol-in-dso.test test started failing after this commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363394 91177308-0d34-0410-b5e6-96231b3b80d8 Rui Ueyama a month ago
7 changed file(s) with 29 addition(s) and 111 deletion(s). Raw diff Collapse all Expand all
None ## Check we do not fail to dump the section headers when
1 ## a .shstrtab section does not have a SHT_STRTAB type.
0 ## 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.
22
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
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
65
76 # LLVM: Name: .shstrtab
87 # LLVM-NEXT: Type: SHT_PROGBITS
98
109 # GNU: [Nr] Name Type
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
10 # GNU: [ 3] .shstrtab 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_DYNSYM
31 - Name: .symtab
32 Info: 42
33 Type: SHT_SYMTAB
34 - Name: .dynsym
35 Info: 26
36 Type: SHT_SYMTAB
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.
46 # CHECK: Name: .symtab
5 # CHECK-NEXT: Type: SHT_DYNAMIC
7 # CHECK-NEXT: Type: SHT_SYMTAB
68
79 --- !ELF
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
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
1618 Symbols:
1719 - Name: foo
1820 Binding: STB_GLOBAL
1818 Machine: EM_X86_64
1919 Sections:
2020 - Name: .dynsym
21 Type: SHT_DYNSYM
21 Type: SHT_SYMTAB
+0
-69
test/tools/yaml2obj/implicit-sections-types.test less more
None ## 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
402402
403403 zero(SHeader);
404404 SHeader.sh_name = DotShStrtab.getOffset(IsStatic ? ".symtab" : ".dynsym");
405
406 if (YAMLSec)
407 SHeader.sh_type = YAMLSec->Type;
408 else
409 SHeader.sh_type = IsStatic ? ELF::SHT_SYMTAB : ELF::SHT_DYNSYM;
405 SHeader.sh_type = IsStatic ? ELF::SHT_SYMTAB : ELF::SHT_DYNSYM;
410406
411407 if (RawSec && !RawSec->Link.empty()) {
412408 // If the Link field is explicitly defined in the document,
470466 ELFYAML::Section *YAMLSec) {
471467 zero(SHeader);
472468 SHeader.sh_name = DotShStrtab.getOffset(Name);
473 SHeader.sh_type = YAMLSec ? YAMLSec->Type : ELF::SHT_STRTAB;
469 SHeader.sh_type = ELF::SHT_STRTAB;
474470 SHeader.sh_addralign = YAMLSec ? (uint64_t)YAMLSec->AddressAlign : 1;
475471
476472 ELFYAML::RawContentSection *RawSec =