1313# RUN: yaml2obj %s -DBITS=64 -DTYPE=ET_REL -o %t64
1414# RUN: llvm-readobj --symbols %t64 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-LLVM
1515# 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
1617# RUN: yaml2obj %s -DBITS=32 -DTYPE=ET_REL -o %t32
1718# RUN: llvm-readobj --symbols %t32 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-LLVM
1819# 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
1921## b) Check dynamic objects.
2022# 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
2225# 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 -
2328# RUN: yaml2obj %s -DBITS=32 -DTYPE=ET_DYN -o %t32.so
2429# RUN: llvm-readobj --symbols %t32.so | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-LLVM
2530# RUN: llvm-readelf --symbols %t32.so | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-GNU32
4146# SYMBOLS-LLVM-NEXT: Binding: Local (0x0)
4247# SYMBOLS-LLVM-NEXT: Type: None (0x0)
4348# SYMBOLS-LLVM-NEXT: Other: 0
44- # SYMBOLS-LLVM-NEXT: Section: Undefined (0x0 )
49+ # SYMBOLS-LLVM-NEXT: Section: .text (0x1 )
4550# SYMBOLS-LLVM-NEXT: }
4651# SYMBOLS-LLVM-NEXT: Symbol {
4752# SYMBOLS-LLVM-NEXT: Name: bar (1)
5257# SYMBOLS-LLVM-NEXT: Other: 0
5358# SYMBOLS-LLVM-NEXT: Section: Undefined (0x0)
5459# 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: }
5569# SYMBOLS-LLVM-NEXT:]
5670
57- # SYMBOLS-GNU64:Symbol table '.symtab' contains 3 entries:
71+ # SYMBOLS-GNU64:Symbol table '.symtab' contains 4 entries:
5872# SYMBOLS-GNU64-NEXT: Num: Value Size Type Bind Vis Ndx Name
5973# 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
6175# 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
6284
63- # SYMBOLS-GNU32:Symbol table '.symtab' contains 3 entries:
85+ # SYMBOLS-GNU32:Symbol table '.symtab' contains 4 entries:
6486# SYMBOLS-GNU32-NEXT: Num: Value Size Type Bind Vis Ndx Name
6587# 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
6789# 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
6898
6999## Case 2: Check flag aliases produce identical output
70100# RUN: llvm-readobj --symbols %t64 > %t.symbols
100130## Case 6: Test that the Num index starts from zero at every new symbol table.
101131# RUN: llvm-readelf --symbols %t64 %t64 | FileCheck %s --check-prefix=NUM-INDEX
102132
103- # NUM-INDEX: Symbol table '.symtab' contains 3 entries:
133+ # NUM-INDEX: Symbol table '.symtab' contains 4 entries:
104134# NUM-INDEX-NEXT: Num: {{.*}}
105135# NUM-INDEX-NEXT: 0: {{.*}}
106- # NUM-INDEX: Symbol table '.symtab' contains 3 entries:
136+ # NUM-INDEX: Symbol table '.symtab' contains 4 entries:
107137# NUM-INDEX-NEXT: Num: {{.*}}
108138# NUM-INDEX-NEXT: 0: {{.*}}
109139
@@ -112,11 +142,21 @@ FileHeader:
112142 Class: ELFCLASS[[BITS]]
113143 Data: ELFDATA2LSB
114144 Type: [[TYPE]]
145+ Sections:
146+ - Name: .text
147+ Type: SHT_PROGBITS
148+ - Name: .data
149+ Type: SHT_PROGBITS
115150Symbols:
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
120160DynamicSymbols:
121161 - Name: zed
122162
@@ -232,6 +272,13 @@ Symbols:
232272## Test a symbol defined relative to a section with an invalid name.
233273# RUN: yaml2obj --docnum=3 %s -o %t64.err4
234274# 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
235282
236283--- !ELF
237284FileHeader:
0 commit comments