blob: 621a1779166aa33698592364bf25d8c86bb931fa [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 Clegg6c899ba2018-02-23 05:08:34 +000062
63WASM: 00000000 d .L.str
64WASM-NEXT: U SomeOtherFunction
Sam Clegg8bda5082017-07-10 20:43:26 +000065WASM-NEXT: 00000002 T main
66WASM-NEXT: U puts
Sam Cleggb09cfa52017-08-31 23:22:44 +000067WASM-NEXT: 00000010 D var
Sam Clegg8bda5082017-07-10 20:43:26 +000068
Sam Clegg6c899ba2018-02-23 05:08:34 +000069
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000070COFF64: 00000000 d .data
71COFF64-NEXT: 00000000 t .text
72COFF64-NEXT: 00000000 r ??__Ex@@YAXXZ
73COFF64-NEXT: 00000000 d L.str
Rafael Espindola4fb845f2015-05-22 13:17:31 +000074COFF64-NEXT: U SomeOtherFunction
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000075COFF64-NEXT: 00000000 T main
Rafael Espindola4fb845f2015-05-22 13:17:31 +000076COFF64-NEXT: U puts
Michael J. Spencer2d67ed82011-01-20 06:39:15 +000077
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000078COFF-COMMON: 00000000 b .bss
79COFF-COMMON-NEXT: 00000000 d .data
80COFF-COMMON-NEXT: 00000000 d .drectve
81COFF-COMMON-NEXT: 00000000 n .file
82COFF-COMMON-NEXT: 00000000 r .rdata$zzz
83COFF-COMMON-NEXT: 00000000 t .text
84COFF-COMMON-NEXT: C _a
Rafael Espindolafb66ef02014-02-04 23:18:52 +000085
86
Rafael Espindola0d6b3472013-07-22 19:24:34 +000087ELF-NOT: U
Michael J. Spencer2d67ed82011-01-20 06:39:15 +000088ELF: U SomeOtherFunction
89ELF: 00000000 T main
90ELF: U puts
Danil Malyshevcbe72fc2011-11-29 17:40:10 +000091
Meador Ingef74d9992016-11-23 20:17:15 +000092ELF-SIZE: U SomeOtherFunction
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000093ELF-SIZE-NEXT: 00000000 00000024 T main
Meador Ingef74d9992016-11-23 20:17:15 +000094ELF-SIZE-NEXT: U puts
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000095
Kevin Enderby08e1bbd2014-07-24 23:31:52 +000096ELF-o: {{.*}}/trivial-object-test.elf-i386: U SomeOtherFunction
97ELF-o: {{.*}}/trivial-object-test.elf-i386: 00000000 T main
98ELF-o: {{.*}}/trivial-object-test.elf-i386: U puts
99
Kevin Enderby49b4f532014-07-28 23:17:38 +0000100ELF-u: U SomeOtherFunction
101ELF-u: U puts
102
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000103ELF64: U SomeOtherFunction
104ELF64: 0000000000000000 T main
105ELF64: U puts
Danil Malyshevcbe72fc2011-11-29 17:40:10 +0000106
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000107WEAK-ELF64: w f1
108WEAK-ELF64: 0000000000000000 W f2
109WEAK-ELF64: v x1
110WEAK-ELF64: 0000000000000000 V x2
111
112ABSOLUTE-ELF64: 0000000000000123 a a1
113ABSOLUTE-ELF64: 0000000000000123 A a2
Rafael Espindola02eac9a2014-02-05 04:36:47 +0000114
Kevin Enderby1b985af2014-05-20 23:04:47 +0000115macho: U _SomeOtherFunction
Rafael Espindolaa1356322013-11-02 05:03:24 +0000116macho: 00000000 T _main
Kevin Enderby1b985af2014-05-20 23:04:47 +0000117macho: U _puts
Danil Malyshevcbe72fc2011-11-29 17:40:10 +0000118
Kevin Enderbyacaaf902014-07-03 18:18:50 +0000119macho-U-NOT: U _SomeOtherFunction
120macho-U: 00000000 T _main
121macho-U-NOT: U _puts
122
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000123macho64: 0000000000000028 s L_.str
Kevin Enderby1b985af2014-05-20 23:04:47 +0000124macho64: U _SomeOtherFunction
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000125macho64: 0000000000000000 T _main
Kevin Enderby1b985af2014-05-20 23:04:47 +0000126macho64: U _puts
Rafael Espindolab4865d62014-04-03 00:19:35 +0000127
Kevin Enderby1e1b9922014-06-19 22:49:21 +0000128macho-tdb: 0000000000000030 s EH_frame0
129macho-tdb: 0000000000000070 b _b
130macho-tdb: 000000000000000c D _d
131macho-tdb: 0000000000000000 T _t
132macho-tdb: 0000000000000048 S _t.eh
Rafael Espindolab4865d62014-04-03 00:19:35 +0000133
Kevin Enderby0fd8aac2014-07-03 21:51:07 +0000134macho-j: EH_frame0
135macho-j: _b
136macho-j: _d
137macho-j: _t
138macho-j: _t.eh
139
Kevin Enderby25a614b2014-07-02 23:23:58 +0000140macho-r: 0000000000000048 S _t.eh
141macho-r-NEXT: 0000000000000000 T _t
142macho-r-NEXT: 000000000000000c D _d
143macho-r-NEXT: 0000000000000070 b _b
144macho-r-NEXT: 0000000000000030 s EH_frame0
145
Kevin Enderbyfe6ad972014-07-11 20:30:00 +0000146macho-s: 000000000000000c D _d
147macho-s-NOT: 0000000000000048 S _t.eh
148macho-s-NOT: 0000000000000000 T _t
149macho-s-NOT: 0000000000000070 b _b
150macho-s-NOT: 0000000000000030 s EH_frame0
151
Kevin Enderby77b968e2014-07-16 17:38:26 +0000152macho-x: 0000000000000030 0e 05 0000 00000010 EH_frame0
153macho-x: 0000000000000070 0e 03 0000 0000000d _b
154macho-x: 000000000000000c 0f 02 0000 00000004 _d
155macho-x: 0000000000000000 0f 01 0000 00000001 _t
156macho-x: 0000000000000048 0f 05 0000 00000007 _t.eh
157
Kevin Enderby08e1bbd2014-07-24 23:31:52 +0000158
159macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000030 s EH_frame0
160macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000070 b _b
161macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 000000000000000c D _d
162macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000000 T _t
163macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000048 S _t.eh
164
Kevin Enderby407cc212014-07-17 22:47:16 +0000165macho-pa: 0000000000000000 - 00 0000 SO /Volumes/SandBox/
166macho-pa: 0000000000000000 - 00 0000 SO hello.c
167macho-pa: 0000000053c8408d - 03 0001 OSO /Volumes/SandBox/hello.o
168macho-pa: 0000000100000f30 - 01 0000 BNSYM
169macho-pa: 0000000100000f30 - 01 0000 FUN _main
170macho-pa: 000000000000003b - 00 0000 FUN
171macho-pa: 000000000000003b - 01 0000 ENSYM
172macho-pa: 0000000000000000 - 01 0000 SO
173macho-pa: 0000000100000000 T __mh_execute_header
174macho-pa: 0000000100000f30 T _main
175macho-pa: U _printf
176macho-pa: U dyld_stub_binder
177
Kevin Enderby49b4f532014-07-28 23:17:38 +0000178macho-u: _printf
179macho-u: dyld_stub_binder
180
Rafael Espindolab4865d62014-04-03 00:19:35 +0000181Test that nm uses addresses even with ELF .o files.
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000182ELF-SEC-ADDR64: 0000000000000058 D a
183ELF-SEC-ADDR64-NEXT: 000000000000005c D b
184ELF-SEC-ADDR64-NEXT: 0000000000000040 T f
185ELF-SEC-ADDR64-NEXT: 0000000000000050 T g
186ELF-SEC-ADDR64-NEXT: 0000000000000060 D p
Rafael Espindola5091f932014-04-03 02:20:43 +0000187
188
189Test that we drop the thumb bit only from function addresses.
190ELF-THUMB: 00000000 t f
191ELF-THUMB: 00000003 t g
Kevin Enderby4fc2edb2014-06-23 20:27:53 +0000192
193A-OUT: U _SomeOtherFunction
194A-OUT: 00000000 T _main
195A-OUT: U _puts