1 ## ELF section symbols use the corresponding section names when printing
2 ## unnamed symbols. This test verifies this and also that appropriate things
3 ## are printed if the section is somehow invalid.
5 # RUN: yaml2obj %s -o %t1
6 # RUN: llvm-readobj %t1 --symbols --relocations 2>&1 | \
7 # RUN: FileCheck %s -DFILE=%t1 --check-prefix=LLVM1 --implicit-check-not="warning:"
8 # RUN: llvm-readelf %t1 --symbols --relocations 2>&1 | \
9 # RUN: FileCheck %s -DFILE=%t1 --check-prefix=GNU1 --implicit-check-not="warning:"
10 # RUN: llvm-readelf %t1 --symbols -X 2>&1 | \
11 # RUN: FileCheck %s -DFILE=%t1 --check-prefix=GNUX1 --implicit-check-not="warning:"
13 # LLVM1: Relocations [
14 # LLVM1-NEXT: Section (5) .rela.foo {
15 # LLVM1-NEXT: 0x1 R_X86_64_NONE .foo 0x0
16 # LLVM1-NEXT: 0x2 R_X86_64_NONE symbol1 0x0
17 # LLVM1-NEXT: warning: '[[FILE]]': invalid section index: 67
18 # LLVM1-NEXT: 0x3 R_X86_64_NONE <section 67> 0x0
19 # LLVM1-NEXT: 0x4 R_X86_64_NONE symbol2 0x0
20 # LLVM1-NEXT: 0x5 R_X86_64_NONE .bar 0x0
21 # LLVM1-NEXT: 0x6 R_X86_64_NONE symbol3 0x0
22 # LLVM1-NEXT: warning: '[[FILE]]': invalid section index: 66
23 # LLVM1-NEXT: 0x7 R_X86_64_NONE <section 66> 0x0
24 # LLVM1-NEXT: 0x8 R_X86_64_NONE symbol4 0x0
29 # LLVM1: Name: .foo (0)
30 # LLVM1: Name: symbol1 (25)
31 # LLVM1: Name: <section 67> (0)
32 # LLVM1: Name: symbol2 (17)
33 # LLVM1: Name: .bar (0)
34 # LLVM1: Name: symbol3 (9)
35 # LLVM1: Name: <section 66> (0)
36 # LLVM1: Name: symbol4 (1)
37 # LLVM1: warning: '[[FILE]]': a section [index 3] has an invalid sh_name (0xffff) offset which goes past the end of the section name string table
38 # LLVM1: Name: <section 3> (0)
40 # GNU1: Relocation section '.rela.foo' at offset {{.*}} contains 8 entries:
41 # GNU1-NEXT: Offset Info Type Sym. Value Symbol's Name + Addend
42 # GNU1-NEXT: 00000001 00000100 R_X86_64_NONE 00000000 .foo + 0
43 # GNU1-NEXT: 00000002 00000200 R_X86_64_NONE 00000000 symbol1 + 0
44 # GNU1-NEXT: warning: '[[FILE]]': invalid section index: 67
45 # GNU1-NEXT: 00000003 00000300 R_X86_64_NONE 00000000 <section 67> + 0
46 # GNU1-NEXT: 00000004 00000400 R_X86_64_NONE 00000000 symbol2 + 0
47 # GNU1-NEXT: 00000005 00000500 R_X86_64_NONE 00000000 .bar + 0
48 # GNU1-NEXT: 00000006 00000600 R_X86_64_NONE 00000000 symbol3 + 0
49 # GNU1-NEXT: warning: '[[FILE]]': invalid section index: 66
50 # GNU1-NEXT: 00000007 00000700 R_X86_64_NONE 00000000 <section 66> + 0
51 # GNU1-NEXT: 00000008 00000800 R_X86_64_NONE 00000000 symbol4 + 0
53 # GNU1: Symbol table '.symtab' contains 10 entries:
54 # GNU1-NEXT: Num: {{.*}} Type {{.*}} Ndx Name
55 # GNU1-NEXT: 0: {{.*}} NOTYPE {{.*}} UND {{$}}
56 # GNU1-NEXT: 1: {{.*}} SECTION {{.*}} 1 .foo
57 # GNU1-NEXT: 2: {{.*}} SECTION {{.*}} 1 symbol1
58 # GNU1-NEXT: 3: {{.*}} SECTION {{.*}} 67 <section 67>
59 # GNU1-NEXT: 4: {{.*}} SECTION {{.*}} 67 symbol2
60 # GNU1-NEXT: 5: {{.*}} SECTION {{.*}} 2 .bar
61 # GNU1-NEXT: 6: {{.*}} SECTION {{.*}} 2 symbol3
62 # GNU1-NEXT: 7: {{.*}} SECTION {{.*}} 66 <section 66>
63 # GNU1-NEXT: 8: {{.*}} SECTION {{.*}} 66 symbol4
64 # GNU1-NEXT: warning: '[[FILE]]': a section [index 3] has an invalid sh_name (0xffff) offset which goes past the end of the section name string table
65 # GNU1-NEXT: 9: {{.*}} SECTION {{.*}} 3 <section 3>
67 # GNUX1: Symbol table '.symtab' contains 10 entries:
68 # GNUX1-NEXT: Num: {{.*}} Type {{.*}} Ndx(SecName) Name
69 # GNUX1-NEXT: 0: {{.*}} NOTYPE {{.*}} UND {{$}}
70 # GNUX1-NEXT: 1: {{.*}} SECTION {{.*}} 1 (.foo) .foo
71 # GNUX1-NEXT: 2: {{.*}} SECTION {{.*}} 1 (.foo) symbol1
72 # GNUX1-NEXT: warning: '[[FILE]]': invalid section index: 67
73 # GNUX1-NEXT: 3: {{.*}} SECTION {{.*}} 67 <section 67>
74 # GNUX1-NEXT: 4: {{.*}} SECTION {{.*}} 67 symbol2
75 # GNUX1-NEXT: 5: {{.*}} SECTION {{.*}} 2 (.bar) .bar
76 # GNUX1-NEXT: 6: {{.*}} SECTION {{.*}} 2 (.bar) symbol3
77 # GNUX1-NEXT: warning: '[[FILE]]': invalid section index: 66
78 # GNUX1-NEXT: 7: {{.*}} SECTION {{.*}} 66 <section 66>
79 # GNUX1-NEXT: 8: {{.*}} SECTION {{.*}} 66 symbol4
80 # GNUX1-NEXT: warning: '[[FILE]]': a section [index 3] has an invalid sh_name (0xffff) offset which goes past the end of the section name string table
81 # GNUX1-NEXT: 9: {{.*}} SECTION {{.*}} 3 <section 3>
98 Type: SHT_SYMTAB_SHNDX
100 Entries: [ 0, 0, 0, 0, 0, 2, 2, 0x42, 0x42, 0 ]
131 ## Case 1: a valid unnamed section symbol.
135 ## Case 2: a valid named section symbol.
139 ## Case 3: an unnamed section symbol with invalid index.
143 ## Case 4: a named section symbol with invalid index.
147 ## Case 5: a valid unnamed section symbol via SHT_SYMTAB_SHNDX.
151 ## Case 6: a valid named section symbol via SHT_SYMTAB_SHNDX.
155 ## Case 7: a unnamed section symbol via SHT_SYMTAB_SHNDX with invalid index.
159 ## Case 8: a named section symbol via SHT_SYMTAB_SHNDX with invalid index.
163 ## Case 9: a unnamed section symbol with invalid name.
168 # RUN: yaml2obj %s --docnum=2 -o %t2
169 # RUN: llvm-readobj %t2 --symbols 2> %t.llvm.err2 | FileCheck %s --check-prefix=LLVM2
170 # RUN: FileCheck %s --input-file %t.llvm.err2 --check-prefix=WARN2 --implicit-check-not=warning
171 # RUN: llvm-readelf %t2 --symbols 2> %t.gnu.err2 | FileCheck %s --check-prefix=GNU2
172 # RUN: FileCheck %s --input-file %t.gnu.err2 --check-prefix=WARN2 --implicit-check-not=warning
175 # LLVM2: Name: <?> (0)
177 # GNU2: Symbol table '.symtab' contains 2 entries:
178 # GNU2-NEXT: Num: {{.*}} Type {{.*}} Ndx Name
179 # GNU2-NEXT: 0: {{.*}} NOTYPE {{.*}} UND {{$}}
180 # GNU2-NEXT: 1: {{.*}} SECTION {{.*}} RSV[0xffff] <?>
182 # WARN2: warning: '{{.*}}.tmp2': found an extended symbol index (1), but unable to locate the extended symbol index table
190 # Section symbol via SHT_SYMTAB_SHNDX when SHT_SYMTAB_SHNDX is missing.