symbols.test
4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
## This is a general test for --symbols option and its aliases.
## There are also other symbols* tests that check specific things.
## Case 1: Test how llvm-readobj and llvm-readelf dumps symbols.
# RUN: yaml2obj %s --docnum=1 -o %t64
# RUN: llvm-readobj --symbols %t64 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-LLVM
# RUN: llvm-readelf --symbols %t64 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-GNU64
# RUN: yaml2obj %s --docnum=2 -o %t32
# RUN: llvm-readobj --symbols %t32 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-LLVM
# RUN: llvm-readelf --symbols %t32 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-GNU32
# SYMBOLS-LLVM:Symbols [
# SYMBOLS-LLVM-NEXT: Symbol {
# SYMBOLS-LLVM-NEXT: Name: (0)
# SYMBOLS-LLVM-NEXT: Value: 0x0
# SYMBOLS-LLVM-NEXT: Size: 0
# SYMBOLS-LLVM-NEXT: Binding: Local (0x0)
# SYMBOLS-LLVM-NEXT: Type: None (0x0)
# SYMBOLS-LLVM-NEXT: Other: 0
# SYMBOLS-LLVM-NEXT: Section: Undefined (0x0)
# SYMBOLS-LLVM-NEXT: }
# SYMBOLS-LLVM-NEXT: Symbol {
# SYMBOLS-LLVM-NEXT: Name: foo (5)
# SYMBOLS-LLVM-NEXT: Value: 0x1
# SYMBOLS-LLVM-NEXT: Size: 0
# SYMBOLS-LLVM-NEXT: Binding: Local (0x0)
# SYMBOLS-LLVM-NEXT: Type: None (0x0)
# SYMBOLS-LLVM-NEXT: Other: 0
# SYMBOLS-LLVM-NEXT: Section: Undefined (0x0)
# SYMBOLS-LLVM-NEXT: }
# SYMBOLS-LLVM-NEXT: Symbol {
# SYMBOLS-LLVM-NEXT: Name: bar (1)
# SYMBOLS-LLVM-NEXT: Value: 0x2
# SYMBOLS-LLVM-NEXT: Size: 0
# SYMBOLS-LLVM-NEXT: Binding: Local (0x0)
# SYMBOLS-LLVM-NEXT: Type: None (0x0)
# SYMBOLS-LLVM-NEXT: Other: 0
# SYMBOLS-LLVM-NEXT: Section: Undefined (0x0)
# SYMBOLS-LLVM-NEXT: }
# SYMBOLS-LLVM-NEXT:]
# SYMBOLS-GNU64:Symbol table '.symtab' contains 3 entries:
# SYMBOLS-GNU64-NEXT: Num: Value Size Type Bind Vis Ndx Name
# SYMBOLS-GNU64-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
# SYMBOLS-GNU64-NEXT: 1: 0000000000000001 0 NOTYPE LOCAL DEFAULT UND foo
# SYMBOLS-GNU64-NEXT: 2: 0000000000000002 0 NOTYPE LOCAL DEFAULT UND bar
# SYMBOLS-GNU32:Symbol table '.symtab' contains 3 entries:
# SYMBOLS-GNU32-NEXT: Num: Value Size Type Bind Vis Ndx Name
# SYMBOLS-GNU32-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
# SYMBOLS-GNU32-NEXT: 1: 00000001 0 NOTYPE LOCAL DEFAULT UND foo
# SYMBOLS-GNU32-NEXT: 2: 00000002 0 NOTYPE LOCAL DEFAULT UND bar
## Case 2: Check flag aliases produce identical output
# RUN: llvm-readobj --symbols %t64 > %t.symbols
# RUN: llvm-readobj --syms %t64 > %t.syms
# RUN: cmp %t.symbols %t.syms
# RUN: llvm-readobj -t %t64 > %t.t
# RUN: cmp %t.symbols %t.t
# RUN: llvm-readelf -s --elf-output-style=LLVM %t64 > %t.lowers
# RUN: cmp %t.symbols %t.lowers
# RUN: llvm-readelf --symbols %t64 > %t.symbols.gnu
# RUN: llvm-readelf --syms %t64 > %t.syms.gnu
# RUN: cmp %t.symbols.gnu %t.syms.gnu
## There is no -t option in llvm-readelf.
# RUN: not llvm-readelf -t %t64 2>&1 | FileCheck %s --check-prefix=NO-T-ERR
# NO-T-ERR: Unknown command line argument '-t'
## -s is an llvm-readobj option to dump sections.
# RUN: llvm-readobj -s --elf-output-style=GNU %t64 | FileCheck %s --implicit-check-not="Symbol table"
## Case 3: Test that both regular and dynamic symbols are dumped when `--symbols` and `--dyn-symbols`
## are specified together. Note that the order is different for different styles.
# RUN: llvm-readobj --symbols --dyn-symbols %t64 | FileCheck %s --check-prefix=BOTH-LLVM
# RUN: llvm-readelf --symbols --dyn-symbols %t64 | FileCheck %s --check-prefix=BOTH-GNU
# BOTH-LLVM: Symbols [
# BOTH-LLVM: DynamicSymbols [
# BOTH-GNU: Symbol table '.dynsym'
# BOTH-GNU: Symbol table '.symtab'
## Case 4: --symbols implies --dyn-symbols for llvm-readelf.
# RUN: llvm-readobj --symbols %t64 | FileCheck %s --implicit-check-not="DynamicSymbols ["
# RUN: llvm-readelf --symbols %t64 | FileCheck %s --check-prefix=BOTH-GNU
## Case 5: Test that `--dyn-symbols` does not trigger `--symbols` implicitly.
# RUN: llvm-readobj --dyn-symbols %t64 | FileCheck %s --implicit-check-not="{{^}}Symbols ["
# RUN: llvm-readelf --dyn-symbols %t64 | FileCheck %s --implicit-check-not="Symbol table '.symtab'"
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Symbols:
- Name: foo
Value: 0x1
- Name: bar
Value: 0x2
DynamicSymbols:
- Name: zed
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_386
Symbols:
- Name: foo
Value: 0x1
- Name: bar
Value: 0x2
DynamicSymbols:
- Name: zed