13
13
# RUN: yaml2obj %s -DBITS=64 -DTYPE=ET_REL -o %t64
14
14
# RUN: llvm-readobj --symbols %t64 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-LLVM
15
15
# RUN: llvm-readelf --symbols %t64 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-GNU64
16
+ # RUN: llvm-readelf -s --extra-sym-info %t64 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-GNU64X
16
17
# RUN: yaml2obj %s -DBITS=32 -DTYPE=ET_REL -o %t32
17
18
# RUN: llvm-readobj --symbols %t32 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-LLVM
18
19
# RUN: llvm-readelf --symbols %t32 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-GNU32
20
+ # RUN: llvm-readelf -s -X %t32 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-GNU32X
19
21
## b) Check dynamic objects.
20
22
# RUN: yaml2obj %s -DBITS=64 -DTYPE=ET_DYN -o %t64.so
21
- # RUN: llvm-readobj --symbols %t64.so | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-LLVM
23
+ # RUN: llvm-readobj --symbols %t64.so > %t64llvm.txt
24
+ # RUN: FileCheck --input-file=%t64llvm.txt %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-LLVM
22
25
# RUN: llvm-readelf --symbols %t64.so | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-GNU64
26
+ ## --extra-sym-info is a no-op for llvm-readobj.
27
+ # RUN: llvm-readobj --symbols --extra-sym-info %t64.so | diff %t64llvm.txt -
23
28
# RUN: yaml2obj %s -DBITS=32 -DTYPE=ET_DYN -o %t32.so
24
29
# RUN: llvm-readobj --symbols %t32.so | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-LLVM
25
30
# RUN: llvm-readelf --symbols %t32.so | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-GNU32
41
46
# SYMBOLS-LLVM-NEXT: Binding: Local (0x0)
42
47
# SYMBOLS-LLVM-NEXT: Type: None (0x0)
43
48
# SYMBOLS-LLVM-NEXT: Other: 0
44
- # SYMBOLS-LLVM-NEXT: Section: Undefined (0x0 )
49
+ # SYMBOLS-LLVM-NEXT: Section: .text (0x1 )
45
50
# SYMBOLS-LLVM-NEXT: }
46
51
# SYMBOLS-LLVM-NEXT: Symbol {
47
52
# SYMBOLS-LLVM-NEXT: Name: bar (1)
52
57
# SYMBOLS-LLVM-NEXT: Other: 0
53
58
# SYMBOLS-LLVM-NEXT: Section: Undefined (0x0)
54
59
# SYMBOLS-LLVM-NEXT: }
60
+ # SYMBOLS-LLVM-NEXT: Symbol {
61
+ # SYMBOLS-LLVM-NEXT: Name: data (9)
62
+ # SYMBOLS-LLVM-NEXT: Value: 0x3
63
+ # SYMBOLS-LLVM-NEXT: Size: 0
64
+ # SYMBOLS-LLVM-NEXT: Binding: Global (0x1)
65
+ # SYMBOLS-LLVM-NEXT: Type: None (0x0)
66
+ # SYMBOLS-LLVM-NEXT: Other: 0
67
+ # SYMBOLS-LLVM-NEXT: Section: .data (0x2)
68
+ # SYMBOLS-LLVM-NEXT: }
55
69
# SYMBOLS-LLVM-NEXT:]
56
70
57
- # SYMBOLS-GNU64:Symbol table '.symtab' contains 3 entries:
71
+ # SYMBOLS-GNU64:Symbol table '.symtab' contains 4 entries:
58
72
# SYMBOLS-GNU64-NEXT: Num: Value Size Type Bind Vis Ndx Name
59
73
# SYMBOLS-GNU64-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
60
- # SYMBOLS-GNU64-NEXT: 1: 0000000000000001 0 NOTYPE LOCAL DEFAULT UND foo
74
+ # SYMBOLS-GNU64-NEXT: 1: 0000000000000001 0 NOTYPE LOCAL DEFAULT 1 foo
61
75
# SYMBOLS-GNU64-NEXT: 2: 0000000000000002 0 NOTYPE LOCAL DEFAULT UND bar
76
+ # SYMBOLS-GNU64-NEXT: 3: 0000000000000003 0 NOTYPE GLOBAL DEFAULT 2 data
77
+
78
+ # SYMBOLS-GNU64X:Symbol table '.symtab' contains 4 entries:
79
+ #SYMBOLS-GNU64X-NEXT: Num: Value Size Type Bind Vis+Other Ndx(SecName) Name [+ Version Info]
80
+ #SYMBOLS-GNU64X-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
81
+ #SYMBOLS-GNU64X-NEXT: 1: 0000000000000001 0 NOTYPE LOCAL DEFAULT 1 (.text) foo
82
+ #SYMBOLS-GNU64X-NEXT: 2: 0000000000000002 0 NOTYPE LOCAL DEFAULT UND bar
83
+ #SYMBOLS-GNU64X-NEXT: 3: 0000000000000003 0 NOTYPE GLOBAL DEFAULT 2 (.data) data
62
84
63
- # SYMBOLS-GNU32:Symbol table '.symtab' contains 3 entries:
85
+ # SYMBOLS-GNU32:Symbol table '.symtab' contains 4 entries:
64
86
# SYMBOLS-GNU32-NEXT: Num: Value Size Type Bind Vis Ndx Name
65
87
# SYMBOLS-GNU32-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
66
- # SYMBOLS-GNU32-NEXT: 1: 00000001 0 NOTYPE LOCAL DEFAULT UND foo
88
+ # SYMBOLS-GNU32-NEXT: 1: 00000001 0 NOTYPE LOCAL DEFAULT 1 foo
67
89
# SYMBOLS-GNU32-NEXT: 2: 00000002 0 NOTYPE LOCAL DEFAULT UND bar
90
+ # SYMBOLS-GNU32-NEXT: 3: 00000003 0 NOTYPE GLOBAL DEFAULT 2 data
91
+
92
+ # SYMBOLS-GNU32X:Symbol table '.symtab' contains 4 entries:
93
+ #SYMBOLS-GNU32X-NEXT: Num: Value Size Type Bind Vis+Other Ndx(SecName) Name [+ Version Info]
94
+ #SYMBOLS-GNU32X-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
95
+ #SYMBOLS-GNU32X-NEXT: 1: 00000001 0 NOTYPE LOCAL DEFAULT 1 (.text) foo
96
+ #SYMBOLS-GNU32X-NEXT: 2: 00000002 0 NOTYPE LOCAL DEFAULT UND bar
97
+ #SYMBOLS-GNU32X-NEXT: 3: 00000003 0 NOTYPE GLOBAL DEFAULT 2 (.data) data
68
98
69
99
## Case 2: Check flag aliases produce identical output
70
100
# RUN: llvm-readobj --symbols %t64 > %t.symbols
100
130
## Case 6: Test that the Num index starts from zero at every new symbol table.
101
131
# RUN: llvm-readelf --symbols %t64 %t64 | FileCheck %s --check-prefix=NUM-INDEX
102
132
103
- # NUM-INDEX: Symbol table '.symtab' contains 3 entries:
133
+ # NUM-INDEX: Symbol table '.symtab' contains 4 entries:
104
134
# NUM-INDEX-NEXT: Num: {{.*}}
105
135
# NUM-INDEX-NEXT: 0: {{.*}}
106
- # NUM-INDEX: Symbol table '.symtab' contains 3 entries:
136
+ # NUM-INDEX: Symbol table '.symtab' contains 4 entries:
107
137
# NUM-INDEX-NEXT: Num: {{.*}}
108
138
# NUM-INDEX-NEXT: 0: {{.*}}
109
139
@@ -112,11 +142,21 @@ FileHeader:
112
142
Class: ELFCLASS[[BITS]]
113
143
Data: ELFDATA2LSB
114
144
Type: [[TYPE]]
145
+ Sections:
146
+ - Name: .text
147
+ Type: SHT_PROGBITS
148
+ - Name: .data
149
+ Type: SHT_PROGBITS
115
150
Symbols:
116
- - Name: foo
117
- Value: 0x1
118
- - Name: bar
119
- Value: 0x2
151
+ - Name: foo
152
+ Value: 0x1
153
+ Section: .text
154
+ - Name: bar
155
+ Value: 0x2
156
+ - Name: data
157
+ Value: 0x3
158
+ Binding: STB_GLOBAL
159
+ Section: .data
120
160
DynamicSymbols:
121
161
- Name: zed
122
162
@@ -232,6 +272,13 @@ Symbols:
232
272
## Test a symbol defined relative to a section with an invalid name.
233
273
# RUN: yaml2obj --docnum=3 %s -o %t64.err4
234
274
# RUN: llvm-readelf -s %t64.err4 2>&1 | FileCheck /dev/null --implicit-check-not=warning:
275
+ # RUN: llvm-readelf -s -X %t64.err4 2>&1 | \
276
+ # RUN: FileCheck %s -DFILE=%t64.err4 --check-prefix=INVALID-SECNAME-GNU --implicit-check-not=warning:
277
+
278
+ # INVALID-SECNAME-GNU: Num: Value Size Type Bind Vis+Other Ndx(SecName) Name [+ Version Info]
279
+ # INVALID-SECNAME-GNU-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
280
+ # INVALID-SECNAME-GNU-NEXT: warning: '[[FILE]]': a section [index 1] has an invalid sh_name (0xffff) offset which goes past the end of the section name string table
281
+ # INVALID-SECNAME-GNU-NEXT: 1: 00000000 0 NOTYPE LOCAL DEFAULT 1 foo
235
282
236
283
--- !ELF
237
284
FileHeader:
0 commit comments