blob: f1aadd5cccf59e3610c366aa20de94f84cb29e47 [file] [log] [blame]
David Majnemer51ff5592014-11-06 08:10:41 +00001RUN: yaml2obj %p/Inputs/COFF/i386.yaml | llvm-nm -a -S - \
Rafael Espindola4fb845f2015-05-22 13:17:31 +00002RUN: | FileCheck %s -check-prefix COFF32
David Majnemer51ff5592014-11-06 08:10:41 +00003RUN: yaml2obj %p/Inputs/COFF/x86-64.yaml | llvm-nm -a -S - \
Rafael Espindola4fb845f2015-05-22 13:17:31 +00004RUN: | FileCheck %s -check-prefix COFF64
Sam Clegg8bda5082017-07-10 20:43:26 +00005RUN: llvm-nm %p/Inputs/trivial-object-test.wasm \
6RUN: | FileCheck %s -check-prefix WASM
Matt Beaumont-Gay1c1a2b82011-10-31 23:56:52 +00007RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 \
Michael J. Spencer2d67ed82011-01-20 06:39:15 +00008RUN: | FileCheck %s -check-prefix ELF
Rafael Espindolaf7cfed42015-05-22 13:28:35 +00009RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 -S \
10RUN: | FileCheck %s -check-prefix ELF-SIZE
Kevin Enderby08e1bbd2014-07-24 23:31:52 +000011RUN: llvm-nm -o %p/Inputs/trivial-object-test.elf-i386 \
12RUN: | FileCheck %s -check-prefix ELF-o
Kevin Enderby49b4f532014-07-28 23:17:38 +000013RUN: llvm-nm -u %p/Inputs/trivial-object-test.elf-i386 \
14RUN: | FileCheck %s -check-prefix ELF-u
Matt Beaumont-Gay1c1a2b82011-10-31 23:56:52 +000015RUN: llvm-nm %p/Inputs/trivial-object-test.elf-x86-64 \
Kevin Enderby6abc2e52014-05-09 23:57:49 +000016RUN: | FileCheck %s -check-prefix ELF64
Rafael Espindolaf42c58d2014-02-04 23:53:15 +000017RUN: llvm-nm %p/Inputs/weak.elf-x86-64 \
Kevin Enderby6abc2e52014-05-09 23:57:49 +000018RUN: | FileCheck %s -check-prefix WEAK-ELF64
Rafael Espindola02eac9a2014-02-05 04:36:47 +000019RUN: llvm-nm %p/Inputs/absolute.elf-x86-64 \
Kevin Enderby6abc2e52014-05-09 23:57:49 +000020RUN: | FileCheck %s -check-prefix ABSOLUTE-ELF64
Danil Malyshevcbe72fc2011-11-29 17:40:10 +000021RUN: llvm-nm %p/Inputs/trivial-object-test.macho-i386 \
22RUN: | FileCheck %s -check-prefix macho
Kevin Enderbyacaaf902014-07-03 18:18:50 +000023RUN: llvm-nm -U %p/Inputs/trivial-object-test.macho-i386 \
24RUN: | FileCheck %s -check-prefix macho-U
Danil Malyshevcbe72fc2011-11-29 17:40:10 +000025RUN: llvm-nm %p/Inputs/trivial-object-test.macho-x86-64 \
26RUN: | FileCheck %s -check-prefix macho64
Kevin Enderby1e1b9922014-06-19 22:49:21 +000027RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 \
28RUN: | FileCheck %s -check-prefix macho-tdb
Kevin Enderby0fd8aac2014-07-03 21:51:07 +000029RUN: llvm-nm -j %p/Inputs/macho-text-data-bss.macho-x86_64 \
30RUN: | FileCheck %s -check-prefix macho-j
Kevin Enderby25a614b2014-07-02 23:23:58 +000031RUN: llvm-nm -r %p/Inputs/macho-text-data-bss.macho-x86_64 \
32RUN: | FileCheck %s -check-prefix macho-r
Kevin Enderbyfe6ad972014-07-11 20:30:00 +000033RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 -s __DATA __data \
34RUN: | FileCheck %s -check-prefix macho-s
Kevin Enderby77b968e2014-07-16 17:38:26 +000035RUN: llvm-nm -x %p/Inputs/macho-text-data-bss.macho-x86_64 \
36RUN: | FileCheck %s -check-prefix macho-x
Kevin Enderby08e1bbd2014-07-24 23:31:52 +000037RUN: llvm-nm -o %p/Inputs/macho-text-data-bss.macho-x86_64 \
38RUN: | FileCheck %s -check-prefix macho-o
Kevin Enderby407cc212014-07-17 22:47:16 +000039RUN: llvm-nm -p -a %p/Inputs/macho-hello-g.macho-x86_64 \
40RUN: | FileCheck %s -check-prefix macho-pa
Kevin Enderby49b4f532014-07-28 23:17:38 +000041RUN: llvm-nm -u %p/Inputs/macho-hello-g.macho-x86_64 \
42RUN: | FileCheck %s -check-prefix macho-u
David Majnemerc7d7c6f2014-10-31 05:07:00 +000043RUN: llvm-nm -S -a %p/Inputs/common.coff-i386 \
Rafael Espindolafb66ef02014-02-04 23:18:52 +000044RUN: | FileCheck %s -check-prefix COFF-COMMON
Rafael Espindolab4865d62014-04-03 00:19:35 +000045RUN: llvm-nm %p/Inputs/relocatable-with-section-address.elf-x86-64 \
Kevin Enderby6abc2e52014-05-09 23:57:49 +000046RUN: | FileCheck %s -check-prefix ELF-SEC-ADDR64
Rafael Espindola5091f932014-04-03 02:20:43 +000047RUN: llvm-nm %p/Inputs/thumb-symbols.elf.arm \
48RUN: | FileCheck %s -check-prefix ELF-THUMB
Kevin Enderby4fc2edb2014-06-23 20:27:53 +000049RUN: mkdir -p %t
50RUN: cd %t
51RUN: cp %p/Inputs/trivial-object-test.macho-i386 a.out
52RUN: llvm-nm | FileCheck %s -check-prefix A-OUT
Rafael Espindola5091f932014-04-03 02:20:43 +000053
Michael J. Spencer2d67ed82011-01-20 06:39:15 +000054
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000055COFF32: 00000000 d .data
56COFF32-NEXT: 00000000 t .text
57COFF32-NEXT: 00000000 d L_.str
Rafael Espindola4fb845f2015-05-22 13:17:31 +000058COFF32-NEXT: U _SomeOtherFunction
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000059COFF32-NEXT: 00000000 T _main
Rafael Espindola4fb845f2015-05-22 13:17:31 +000060COFF32-NEXT: U _puts
61
Sam Clegg8bda5082017-07-10 20:43:26 +000062WASM: U SomeOtherFunction
63WASM-NEXT: 00000002 T main
64WASM-NEXT: U puts
65WASM-NEXT: 00000001 D var
66
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000067COFF64: 00000000 d .data
68COFF64-NEXT: 00000000 t .text
69COFF64-NEXT: 00000000 r ??__Ex@@YAXXZ
70COFF64-NEXT: 00000000 d L.str
Rafael Espindola4fb845f2015-05-22 13:17:31 +000071COFF64-NEXT: U SomeOtherFunction
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000072COFF64-NEXT: 00000000 T main
Rafael Espindola4fb845f2015-05-22 13:17:31 +000073COFF64-NEXT: U puts
Michael J. Spencer2d67ed82011-01-20 06:39:15 +000074
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000075COFF-COMMON: 00000000 b .bss
76COFF-COMMON-NEXT: 00000000 d .data
77COFF-COMMON-NEXT: 00000000 d .drectve
78COFF-COMMON-NEXT: 00000000 n .file
79COFF-COMMON-NEXT: 00000000 r .rdata$zzz
80COFF-COMMON-NEXT: 00000000 t .text
81COFF-COMMON-NEXT: C _a
Rafael Espindolafb66ef02014-02-04 23:18:52 +000082
83
Rafael Espindola0d6b3472013-07-22 19:24:34 +000084ELF-NOT: U
Michael J. Spencer2d67ed82011-01-20 06:39:15 +000085ELF: U SomeOtherFunction
86ELF: 00000000 T main
87ELF: U puts
Danil Malyshevcbe72fc2011-11-29 17:40:10 +000088
Meador Ingef74d9992016-11-23 20:17:15 +000089ELF-SIZE: U SomeOtherFunction
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000090ELF-SIZE-NEXT: 00000000 00000024 T main
Meador Ingef74d9992016-11-23 20:17:15 +000091ELF-SIZE-NEXT: U puts
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000092
Kevin Enderby08e1bbd2014-07-24 23:31:52 +000093ELF-o: {{.*}}/trivial-object-test.elf-i386: U SomeOtherFunction
94ELF-o: {{.*}}/trivial-object-test.elf-i386: 00000000 T main
95ELF-o: {{.*}}/trivial-object-test.elf-i386: U puts
96
Kevin Enderby49b4f532014-07-28 23:17:38 +000097ELF-u: U SomeOtherFunction
98ELF-u: U puts
99
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000100ELF64: U SomeOtherFunction
101ELF64: 0000000000000000 T main
102ELF64: U puts
Danil Malyshevcbe72fc2011-11-29 17:40:10 +0000103
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000104WEAK-ELF64: w f1
105WEAK-ELF64: 0000000000000000 W f2
106WEAK-ELF64: v x1
107WEAK-ELF64: 0000000000000000 V x2
108
109ABSOLUTE-ELF64: 0000000000000123 a a1
110ABSOLUTE-ELF64: 0000000000000123 A a2
Rafael Espindola02eac9a2014-02-05 04:36:47 +0000111
Kevin Enderby1b985af2014-05-20 23:04:47 +0000112macho: U _SomeOtherFunction
Rafael Espindolaa1356322013-11-02 05:03:24 +0000113macho: 00000000 T _main
Kevin Enderby1b985af2014-05-20 23:04:47 +0000114macho: U _puts
Danil Malyshevcbe72fc2011-11-29 17:40:10 +0000115
Kevin Enderbyacaaf902014-07-03 18:18:50 +0000116macho-U-NOT: U _SomeOtherFunction
117macho-U: 00000000 T _main
118macho-U-NOT: U _puts
119
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000120macho64: 0000000000000028 s L_.str
Kevin Enderby1b985af2014-05-20 23:04:47 +0000121macho64: U _SomeOtherFunction
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000122macho64: 0000000000000000 T _main
Kevin Enderby1b985af2014-05-20 23:04:47 +0000123macho64: U _puts
Rafael Espindolab4865d62014-04-03 00:19:35 +0000124
Kevin Enderby1e1b9922014-06-19 22:49:21 +0000125macho-tdb: 0000000000000030 s EH_frame0
126macho-tdb: 0000000000000070 b _b
127macho-tdb: 000000000000000c D _d
128macho-tdb: 0000000000000000 T _t
129macho-tdb: 0000000000000048 S _t.eh
Rafael Espindolab4865d62014-04-03 00:19:35 +0000130
Kevin Enderby0fd8aac2014-07-03 21:51:07 +0000131macho-j: EH_frame0
132macho-j: _b
133macho-j: _d
134macho-j: _t
135macho-j: _t.eh
136
Kevin Enderby25a614b2014-07-02 23:23:58 +0000137macho-r: 0000000000000048 S _t.eh
138macho-r-NEXT: 0000000000000000 T _t
139macho-r-NEXT: 000000000000000c D _d
140macho-r-NEXT: 0000000000000070 b _b
141macho-r-NEXT: 0000000000000030 s EH_frame0
142
Kevin Enderbyfe6ad972014-07-11 20:30:00 +0000143macho-s: 000000000000000c D _d
144macho-s-NOT: 0000000000000048 S _t.eh
145macho-s-NOT: 0000000000000000 T _t
146macho-s-NOT: 0000000000000070 b _b
147macho-s-NOT: 0000000000000030 s EH_frame0
148
Kevin Enderby77b968e2014-07-16 17:38:26 +0000149macho-x: 0000000000000030 0e 05 0000 00000010 EH_frame0
150macho-x: 0000000000000070 0e 03 0000 0000000d _b
151macho-x: 000000000000000c 0f 02 0000 00000004 _d
152macho-x: 0000000000000000 0f 01 0000 00000001 _t
153macho-x: 0000000000000048 0f 05 0000 00000007 _t.eh
154
Kevin Enderby08e1bbd2014-07-24 23:31:52 +0000155
156macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000030 s EH_frame0
157macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000070 b _b
158macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 000000000000000c D _d
159macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000000 T _t
160macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000048 S _t.eh
161
Kevin Enderby407cc212014-07-17 22:47:16 +0000162macho-pa: 0000000000000000 - 00 0000 SO /Volumes/SandBox/
163macho-pa: 0000000000000000 - 00 0000 SO hello.c
164macho-pa: 0000000053c8408d - 03 0001 OSO /Volumes/SandBox/hello.o
165macho-pa: 0000000100000f30 - 01 0000 BNSYM
166macho-pa: 0000000100000f30 - 01 0000 FUN _main
167macho-pa: 000000000000003b - 00 0000 FUN
168macho-pa: 000000000000003b - 01 0000 ENSYM
169macho-pa: 0000000000000000 - 01 0000 SO
170macho-pa: 0000000100000000 T __mh_execute_header
171macho-pa: 0000000100000f30 T _main
172macho-pa: U _printf
173macho-pa: U dyld_stub_binder
174
Kevin Enderby49b4f532014-07-28 23:17:38 +0000175macho-u: _printf
176macho-u: dyld_stub_binder
177
Rafael Espindolab4865d62014-04-03 00:19:35 +0000178Test that nm uses addresses even with ELF .o files.
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000179ELF-SEC-ADDR64: 0000000000000058 D a
180ELF-SEC-ADDR64-NEXT: 000000000000005c D b
181ELF-SEC-ADDR64-NEXT: 0000000000000040 T f
182ELF-SEC-ADDR64-NEXT: 0000000000000050 T g
183ELF-SEC-ADDR64-NEXT: 0000000000000060 D p
Rafael Espindola5091f932014-04-03 02:20:43 +0000184
185
186Test that we drop the thumb bit only from function addresses.
187ELF-THUMB: 00000000 t f
188ELF-THUMB: 00000003 t g
Kevin Enderby4fc2edb2014-06-23 20:27:53 +0000189
190A-OUT: U _SomeOtherFunction
191A-OUT: 00000000 T _main
192A-OUT: U _puts