demangle.test
7.71 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
## Show that llvm-readelf + llvm-readobj demangle symbol names in symbol tables
## (including dynamic symbols), relocations (including dynamic relocations), and groups.
# RUN: yaml2obj %s > %t.so
## Check LLVM output style.
# RUN: llvm-readobj --symbols --relocations --dyn-symbols --dyn-relocations \
# RUN: --elf-section-groups --elf-cg-profile --addrsig \
# RUN: --demangle %t.so > %t.llvm.long
# RUN: llvm-readobj --symbols --relocations --dyn-symbols --dyn-relocations \
# RUN: --elf-section-groups --elf-cg-profile --addrsig \
# RUN: -C %t.so > %t.llvm.short
# RUN: FileCheck %s --input-file %t.llvm.long --check-prefixes=LLVM-COMMON,LLVM-DEMANGLE
# RUN: diff %t.llvm.long %t.llvm.short
## Check that default is no demangling.
# RUN: llvm-readobj --symbols --relocations --dyn-symbols --dyn-relocations \
# RUN: --elf-section-groups --elf-cg-profile --addrsig \
# RUN: %t.so > %t.llvm.default
# RUN: llvm-readobj --symbols --relocations --dyn-symbols --dyn-relocations \
# RUN: --elf-section-groups --elf-cg-profile --addrsig \
# RUN: --demangle=false %t.so > %t.llvm.nodemangle
# RUN: FileCheck %s --input-file %t.llvm.default --check-prefixes=LLVM-COMMON,LLVM-MANGLED
# RUN: diff %t.llvm.default %t.llvm.nodemangle
# LLVM-COMMON: Relocations [
# LLVM-COMMON: Section {{.*}} .rela.text.foo {
# LLVM-DEMANGLE-NEXT: {{ }}foo(char){{ }}
# LLVM-MANGLED-NEXT: {{ }}_Z3fooc{{ }}
# LLVM-COMMON-NEXT: }
# LLVM-COMMON: ]
# LLVM-COMMON: Dynamic Relocations {
# LLVM-DEMANGLE-NEXT: {{ }}foo(int){{ }}
# LLVM-MANGLED-NEXT: {{ }}_Z3fooi{{ }}
# LLVM-COMMON-NEXT: }
# LLVM-COMMON: Symbols [
# LLVM-DEMANGLE: Name: foo(char){{ }}
# LLVM-DEMANGLE: Name: blah(float){{ }}
# LLVM-MANGLED: Name: _Z3fooc{{ }}
# LLVM-MANGLED: Name: _Z4blahf{{ }}
# LLVM-COMMON: ]
# LLVM-COMMON: DynamicSymbols [
# LLVM-DEMANGLE: Name: foo(int){{ }}
# LLVM-MANGLED: Name: _Z3fooi{{ }}
# LLVM-COMMON: ]
# LLVM-COMMON: Groups {
# LLVM-DEMANGLE: Signature: foo(char){{$}}
# LLVM-MANGLED: Signature: _Z3fooc{{$}}
# LLVM-COMMON: }
# LLVM-COMMON: CGProfile [
# LLVM-DEMANGLE: From: foo(char){{ }}
# LLVM-DEMANGLE: To: blah(float){{ }}
# LLVM-MANGLED: From: _Z3fooc{{ }}
# LLVM-MANGLED: To: _Z4blahf{{ }}
# LLVM-COMMON: ]
# LLVM-COMMON: Addrsig [
# LLVM-DEMANGLE-NEXT: Sym: foo(char){{ }}
# LLVM-DEMANGLE-NEXT: Sym: blah(float){{ }}
# LLVM-MANGLED-NEXT: Sym: _Z3fooc{{ }}
# LLVM-MANGLED-NEXT: Sym: _Z4blahf{{ }}
# LLVM-COMMON-NEXT: ]
## Check GNU output style.
# RUN: llvm-readelf --symbols --relocations --dyn-symbols --dyn-relocations \
# RUN: --elf-section-groups --demangle %t.so > %t.gnu.long
# RUN: llvm-readelf --symbols --relocations --dyn-symbols --dyn-relocations \
# RUN: --elf-section-groups -C %t.so > %t.gnu.short
# RUN: FileCheck %s --input-file %t.gnu.long --check-prefixes=GNU-COMMON,GNU-DEMANGLE
# RUN: diff %t.gnu.long %t.gnu.short
## Check that default is no demangling.
# RUN: llvm-readelf --symbols --relocations --dyn-symbols --dyn-relocations \
# RUN: --elf-section-groups %t.so > %t.gnu.default
# RUN: llvm-readelf --symbols --relocations --dyn-symbols --dyn-relocations \
# RUN: --elf-section-groups --demangle=false %t.so > %t.gnu.nodemangle
# RUN: FileCheck %s --input-file %t.gnu.default --check-prefixes=GNU-COMMON,GNU-MANGLED
# RUN: diff %t.gnu.default %t.gnu.nodemangle
# GNU-COMMON: Relocation section '.rela.text.foo' at offset {{.*}} contains 1 entries:
# GNU-COMMON-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
# GNU-DEMANGLE-NEXT: foo(char){{ }}
# GNU-MANGLED-NEXT: _Z3fooc{{ }}
# GNU-COMMON: 'RELA' relocation section at offset {{.*}} contains 24 bytes:
# GNU-COMMON-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
# GNU-DEMANGLE-NEXT: foo(int){{ }}
# GNU-MANGLED-NEXT: _Z3fooi{{ }}
# GNU-COMMON: Symbol table '.dynsym' contains 2 entries:
# GNU-COMMON-NEXT: Num: Value Size Type Bind Vis Ndx Name
# GNU-COMMON-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
# GNU-DEMANGLE-NEXT: foo(int){{$}}
# GNU-MANGLED-NEXT: _Z3fooi{{$}}
# GNU-COMMON: Symbol table '.symtab' contains 3 entries:
# GNU-COMMON-NEXT: Num: Value Size Type Bind Vis Ndx Name
# GNU-COMMON-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
# GNU-DEMANGLE-NEXT: foo(char){{$}}
# GNU-DEMANGLE-NEXT: blah(float){{$}}
# GNU-MANGLED-NEXT: _Z3fooc{{$}}
# GNU-MANGLED-NEXT: _Z4blahf{{$}}
# GNU-COMMON: COMDAT group section [{{.*}}] `.group'
# GNU-DEMANGLE-SAME: [foo(char)]
# GNU-MANGLED-SAME: [_Z3fooc]
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .dynstr
Type: SHT_STRTAB
Flags: [ SHF_ALLOC ]
AddressAlign: 0x100
EntSize: 0x1
- Name: .dynsym
Type: SHT_DYNSYM
Flags: [ SHF_ALLOC ]
Link: .dynstr
Address: 0x100
AddressAlign: 0x100
EntSize: 0x18
- Name: .rela.dyn
Type: SHT_RELA
Flags: [ SHF_ALLOC ]
Link: .dynsym
Info: .text.foo
Address: 0x200
AddressAlign: 0x100
EntSize: 0x18
Relocations:
- Offset: 0x10
Symbol: _Z3fooi
Type: R_X86_64_PC32
Addend: 0x4
- Name: .dynamic
Type: SHT_DYNAMIC
Flags: [ SHF_ALLOC ]
Address: 0x0000000000001000
Link: .dynstr
AddressAlign: 0x0000000000001000
EntSize: 0x0000000000000010
Entries:
- Tag: DT_STRTAB
Value: 0x0000000000000000
- Tag: DT_STRSZ
Value: 0x0000000000000009
- Tag: DT_SYMTAB
Value: 0x0000000000000100
- Tag: DT_SYMENT
Value: 0x0000000000000018
- Tag: DT_RELA
Value: 0x0000000000000200
- Tag: DT_RELASZ
Value: 0x0000000000000018
- Tag: DT_RELAENT
Value: 0x0000000000000018
- Tag: DT_NULL
Value: 0x0000000000000000
- Name: .text.foo
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
Size: 0x40
Address: 0x2000
AddressAlign: 0x2000
- Name: .group
Type: SHT_GROUP
Link: .symtab
Info: _Z3fooc
Members:
- SectionOrType: GRP_COMDAT
- SectionOrType: .text.foo
- Name: .rela.text.foo
Type: SHT_RELA
Link: .symtab
Info: .text.foo
Relocations:
- Offset: 0x10
Symbol: _Z3fooc
Type: R_X86_64_PC32
- Name: .llvm.call-graph-profile
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Link: .symtab
EntSize: 16
Content: "01000000020000002000000000000000"
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Link: .symtab
Content: "0102"
Symbols:
- Name: _Z3fooc
Type: STT_FUNC
Section: .text.foo
Binding: STB_GLOBAL
- Name: _Z4blahf
Type: STT_FUNC
Section: .text.foo
Binding: STB_GLOBAL
DynamicSymbols:
- Name: _Z3fooi
Binding: STB_GLOBAL
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
VAddr: 0x0
PAddr: 0x0
Sections:
- Section: .dynsym
- Section: .dynstr
- Section: .rela.dyn
- Section: .dynamic
- Section: .text.foo
- Type: PT_DYNAMIC
Flags: [ PF_R ]
VAddr: 0x1000
PAddr: 0x1000
Sections:
- Section: .dynamic