nm-trivial-object.test
10.2 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# RUN: yaml2obj %p/Inputs/COFF/i386.yaml | llvm-nm -a -S - \
# RUN: | FileCheck %s -check-prefix COFF32
# COFF32: 00000000 d .data
# COFF32-NEXT: 00000000 t .text
# COFF32-NEXT: 00000000 d L_.str
# COFF32-NEXT: U _SomeOtherFunction
# COFF32-NEXT: 00000000 T _main
# COFF32-NEXT: U _puts
# RUN: yaml2obj %p/Inputs/COFF/x86-64.yaml | llvm-nm -a -S - \
# RUN: | FileCheck %s -check-prefix COFF64
# COFF64: 00000000 d .data
# COFF64-NEXT: 00000000 t .text
# COFF64-NEXT: 00000000 r ??__Ex@@YAXXZ
# COFF64-NEXT: 00000000 d L.str
# COFF64-NEXT: U SomeOtherFunction
# COFF64-NEXT: 00000000 T main
# COFF64-NEXT: U puts
# RUN: llvm-nm %p/Inputs/trivial-object-test.wasm \
# RUN: | FileCheck %s -check-prefix WASM
# WASM: 00000000 d .L.str
# WASM-NEXT: 00000019 t .LSomeOtherFunction_bitcast
# WASM-NEXT: U SomeOtherFunction
# WASM-NEXT: 00000001 T main
# WASM-NEXT: U puts
# WASM-NEXT: 00000010 D var
# RUN: yaml2obj --docnum=1 %s -o %t.elf-i386
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_386
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Symbols:
- Name: main
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Size: 0x0000000000000024
- Name: SomeOtherFunction
Binding: STB_GLOBAL
- Name: puts
Binding: STB_GLOBAL
# RUN: llvm-nm %t.elf-i386 | FileCheck %s -check-prefix=ELF
# ELF-NOT: U
# ELF: U SomeOtherFunction
# ELF: 00000000 T main
# ELF: U puts
# RUN: llvm-nm -o %t.elf-i386 | FileCheck %s -DFILE=%t.elf-i386 -check-prefix=ELF-o
# RUN: llvm-nm %t.elf-i386 -S | FileCheck %s -check-prefix ELF-SIZE
# ELF-SIZE: U SomeOtherFunction
# ELF-SIZE-NEXT: 00000000 00000024 T main
# ELF-SIZE-NEXT: U puts
# ELF-o-NOT: U
# ELF-o: [[FILE]]: U SomeOtherFunction
# ELF-o: [[FILE]]: 00000000 T main
# ELF-o: [[FILE]]: U puts
# RUN: llvm-nm -u %t.elf-i386 | FileCheck %s -check-prefix ELF-u
# ELF-u: U SomeOtherFunction
# ELF-u: U puts
## Test different ELF symbols for 64-bit platform.
# RUN: yaml2obj --docnum=2 %s -o %t.elf-x86-64
# RUN: llvm-nm %t.elf-x86-64 | FileCheck %s -check-prefix ELF64
# ELF64: U SomeOtherFunction
# ELF64: 0000000000000123 a absSym1
# ELF64: 0000000000000123 A absSym2
# ELF64: 0000000000002000 D dataSym1
# ELF64: 0000000000002004 D dataSym2
# ELF64: 0000000000001000 T textSym1
# ELF64: 0000000000001004 T textSym2
# ELF64: U undefinedSym
# ELF64: v weakObject1
# ELF64: 0000000000001000 V weakObject2
# ELF64: w weakSym1
# ELF64: 0000000000001000 W weakSym2
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x1000
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_WRITE ]
Address: 0x2000
Symbols:
- Name: absSym1
Index: SHN_ABS
Value: 0x0000000000000123
- Name: absSym2
Index: SHN_ABS
Binding: STB_GLOBAL
Value: 0x0000000000000123
- Name: SomeOtherFunction
Binding: STB_GLOBAL
- Name: undefinedSym
Binding: STB_GLOBAL
- Name: weakObject1
Type: STT_OBJECT
Binding: STB_WEAK
- Name: weakObject2
Type: STT_OBJECT
Section: .text
Binding: STB_WEAK
- Name: weakSym1
Binding: STB_WEAK
- Name: weakSym2
Section: .text
Binding: STB_WEAK
- Name: dataSym1
Type: STT_OBJECT
Section: .data
Binding: STB_GLOBAL
Value: 0x0000000000000000
- Name: dataSym2
Type: STT_OBJECT
Section: .data
Binding: STB_GLOBAL
Value: 0x0000000000000004
- Name: textSym1
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Value: 0x0000000000000000
- Name: textSym2
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Value: 0x0000000000000004
## Test llvm-nm shows all symbols with -a.
# RUN: yaml2obj --docnum=3 %s -o %t-a.elf-x86-64
# RUN: llvm-nm -a %t-a.elf-x86-64 | FileCheck %s -check-prefix ELF64-a
# ELF64-a: 00000000 b .bss
# ELF64-a-NEXT: 00000000 n .comment
# ELF64-a-NEXT: 00000000 d .data
# ELF64-a-NEXT: 00000000 N .debug_sec
# ELF64-a-NEXT: 00000000 t .text
# ELF64-a-NEXT: 00000000 a fileSym
# ELF64-a-NEXT: 00000014 T regularSym
# ELF64-a-NEXT: U undefSym
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_386
Sections:
- Name: .rodata
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
- Name: .bss
Type: SHT_NOBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
- Name: .debug_sec
Type: SHT_PROGBITS
- Name: .comment
Type: SHT_PROGBITS
Symbols:
- Name: fileSym
Type: STT_FILE
Index: SHN_ABS
- Name: .text
Type: STT_SECTION
Section: .text
- Name: .data
Type: STT_SECTION
Section: .data
- Name: .bss
Type: STT_SECTION
Section: .bss
- Name: .debug_sec
Type: STT_SECTION
Section: .debug_sec
- Name: .comment
Type: STT_SECTION
Section: .comment
- Name: undefSym
Binding: STB_GLOBAL
- Name: regularSym
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Value: 0x0000000000000014
## Test that we drop the thumb bit only from function addresses.
# RUN: yaml2obj --docnum=4 %s -o %t.elf-arm32
# RUN: llvm-nm %t.elf-arm32 | FileCheck %s -check-prefix ELF-THUMB
# ELF-THUMB: 00000000 t func
# ELF-THUMB: 00000003 t sym
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_ARM
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Symbols:
- Name: func
Type: STT_FUNC
Section: .text
Value: 0x0000000000000001
- Name: sym
Section: .text
Value: 0x0000000000000003
# RUN: llvm-nm %p/Inputs/trivial-object-test.macho-i386 \
# RUN: | FileCheck %s -check-prefix macho
# macho: U _SomeOtherFunction
# macho: 00000000 T _main
# macho: U _puts
# RUN: llvm-nm -U %p/Inputs/trivial-object-test.macho-i386 \
# RUN: | FileCheck %s -check-prefix macho-U
# macho-U-NOT: U _SomeOtherFunction
# macho-U: 00000000 T _main
# macho-U-NOT: U _puts
# RUN: llvm-nm %p/Inputs/trivial-object-test.macho-x86-64 \
# RUN: | FileCheck %s -check-prefix macho64
# macho64: 0000000000000028 s L_.str
# macho64: U _SomeOtherFunction
# macho64: 0000000000000000 T _main
# macho64: U _puts
# RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 \
# RUN: | FileCheck %s -check-prefix macho-tdb
# macho-tdb: 0000000000000030 s EH_frame0
# macho-tdb: 0000000000000070 b _b
# macho-tdb: 000000000000000c D _d
# macho-tdb: 0000000000000000 T _t
# macho-tdb: 0000000000000048 S _t.eh
# RUN: llvm-nm -j %p/Inputs/macho-text-data-bss.macho-x86_64 \
# RUN: | FileCheck %s -check-prefix macho-j
# macho-j: EH_frame0
# macho-j: _b
# macho-j: _d
# macho-j: _t
# macho-j: _t.eh
# RUN: llvm-nm -r %p/Inputs/macho-text-data-bss.macho-x86_64 \
# RUN: | FileCheck %s -check-prefix macho-r
# macho-r: 0000000000000048 S _t.eh
# macho-r-NEXT: 0000000000000000 T _t
# macho-r-NEXT: 000000000000000c D _d
# macho-r-NEXT: 0000000000000070 b _b
# macho-r-NEXT: 0000000000000030 s EH_frame0
# RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 -s __DATA __data \
# RUN: | FileCheck %s -check-prefix macho-s
# macho-s: 000000000000000c D _d
# macho-s-NOT: 0000000000000048 S _t.eh
# macho-s-NOT: 0000000000000000 T _t
# macho-s-NOT: 0000000000000070 b _b
# macho-s-NOT: 0000000000000030 s EH_frame0
# RUN: llvm-nm -x %p/Inputs/macho-text-data-bss.macho-x86_64 \
# RUN: | FileCheck %s -check-prefix macho-x
# macho-x: 0000000000000030 0e 05 0000 00000010 EH_frame0
# macho-x: 0000000000000070 0e 03 0000 0000000d _b
# macho-x: 000000000000000c 0f 02 0000 00000004 _d
# macho-x: 0000000000000000 0f 01 0000 00000001 _t
# macho-x: 0000000000000048 0f 05 0000 00000007 _t.eh
# RUN: llvm-nm -o %p/Inputs/macho-text-data-bss.macho-x86_64 \
# RUN: | FileCheck %s -check-prefix macho-o
# macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000030 s EH_frame0
# macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000070 b _b
# macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 000000000000000c D _d
# macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000000 T _t
# macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000048 S _t.eh
# RUN: llvm-nm -p -a %p/Inputs/macho-hello-g.macho-x86_64 \
# RUN: | FileCheck %s -check-prefix macho-pa
# macho-pa: 0000000000000000 - 00 0000 SO /Volumes/SandBox/
# macho-pa: 0000000000000000 - 00 0000 SO hello.c
# macho-pa: 0000000053c8408d - 03 0001 OSO /Volumes/SandBox/hello.o
# macho-pa: 0000000100000f30 - 01 0000 BNSYM
# macho-pa: 0000000100000f30 - 01 0000 FUN _main
# macho-pa: 000000000000003b - 00 0000 FUN
# macho-pa: 000000000000003b - 01 0000 ENSYM
# macho-pa: 0000000000000000 - 01 0000 SO
# macho-pa: 0000000100000000 T __mh_execute_header
# macho-pa: 0000000100000f30 T _main
# macho-pa: U _printf
# macho-pa: U dyld_stub_binder
# RUN: llvm-nm -u %p/Inputs/macho-hello-g.macho-x86_64 \
# RUN: | FileCheck %s -check-prefix macho-u
# macho-u: _printf
# macho-u: dyld_stub_binder
# RUN: llvm-nm -S -a %p/Inputs/common.coff-i386 \
# RUN: | FileCheck %s -check-prefix COFF-COMMON
# COFF-COMMON: 00000000 b .bss
# COFF-COMMON-NEXT: 00000000 d .data
# COFF-COMMON-NEXT: 00000000 d .drectve
# COFF-COMMON-NEXT: 00000000 n .file
# COFF-COMMON-NEXT: 00000000 r .rdata$zzz
# COFF-COMMON-NEXT: 00000000 t .text
# COFF-COMMON-NEXT: C _a
# RUN: mkdir -p %t
# RUN: cd %t
# RUN: cp %p/Inputs/trivial-object-test.macho-i386 a.out
# RUN: llvm-nm a.out | FileCheck %s -check-prefix A-OUT
# A-OUT: U _SomeOtherFunction
# A-OUT: 00000000 T _main
# A-OUT: U _puts