blob: def6549d65630455643d2655f6ed100a99f0704d [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
Matt Beaumont-Gay1c1a2b82011-10-31 23:56:52 +00005RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 \
Michael J. Spencer2d67ed82011-01-20 06:39:15 +00006RUN: | FileCheck %s -check-prefix ELF
Rafael Espindolaf7cfed42015-05-22 13:28:35 +00007RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 -S \
8RUN: | FileCheck %s -check-prefix ELF-SIZE
Kevin Enderby08e1bbd2014-07-24 23:31:52 +00009RUN: llvm-nm -o %p/Inputs/trivial-object-test.elf-i386 \
10RUN: | FileCheck %s -check-prefix ELF-o
Kevin Enderby49b4f532014-07-28 23:17:38 +000011RUN: llvm-nm -u %p/Inputs/trivial-object-test.elf-i386 \
12RUN: | FileCheck %s -check-prefix ELF-u
Matt Beaumont-Gay1c1a2b82011-10-31 23:56:52 +000013RUN: llvm-nm %p/Inputs/trivial-object-test.elf-x86-64 \
Kevin Enderby6abc2e52014-05-09 23:57:49 +000014RUN: | FileCheck %s -check-prefix ELF64
Rafael Espindolaf42c58d2014-02-04 23:53:15 +000015RUN: llvm-nm %p/Inputs/weak.elf-x86-64 \
Kevin Enderby6abc2e52014-05-09 23:57:49 +000016RUN: | FileCheck %s -check-prefix WEAK-ELF64
Rafael Espindola02eac9a2014-02-05 04:36:47 +000017RUN: llvm-nm %p/Inputs/absolute.elf-x86-64 \
Kevin Enderby6abc2e52014-05-09 23:57:49 +000018RUN: | FileCheck %s -check-prefix ABSOLUTE-ELF64
Danil Malyshevcbe72fc2011-11-29 17:40:10 +000019RUN: llvm-nm %p/Inputs/trivial-object-test.macho-i386 \
20RUN: | FileCheck %s -check-prefix macho
Kevin Enderbyacaaf902014-07-03 18:18:50 +000021RUN: llvm-nm -U %p/Inputs/trivial-object-test.macho-i386 \
22RUN: | FileCheck %s -check-prefix macho-U
Danil Malyshevcbe72fc2011-11-29 17:40:10 +000023RUN: llvm-nm %p/Inputs/trivial-object-test.macho-x86-64 \
24RUN: | FileCheck %s -check-prefix macho64
Kevin Enderby1e1b9922014-06-19 22:49:21 +000025RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 \
26RUN: | FileCheck %s -check-prefix macho-tdb
Kevin Enderby0fd8aac2014-07-03 21:51:07 +000027RUN: llvm-nm -j %p/Inputs/macho-text-data-bss.macho-x86_64 \
28RUN: | FileCheck %s -check-prefix macho-j
Kevin Enderby25a614b2014-07-02 23:23:58 +000029RUN: llvm-nm -r %p/Inputs/macho-text-data-bss.macho-x86_64 \
30RUN: | FileCheck %s -check-prefix macho-r
Kevin Enderbyfe6ad972014-07-11 20:30:00 +000031RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 -s __DATA __data \
32RUN: | FileCheck %s -check-prefix macho-s
Kevin Enderby77b968e2014-07-16 17:38:26 +000033RUN: llvm-nm -x %p/Inputs/macho-text-data-bss.macho-x86_64 \
34RUN: | FileCheck %s -check-prefix macho-x
Kevin Enderby08e1bbd2014-07-24 23:31:52 +000035RUN: llvm-nm -o %p/Inputs/macho-text-data-bss.macho-x86_64 \
36RUN: | FileCheck %s -check-prefix macho-o
Kevin Enderby407cc212014-07-17 22:47:16 +000037RUN: llvm-nm -p -a %p/Inputs/macho-hello-g.macho-x86_64 \
38RUN: | FileCheck %s -check-prefix macho-pa
Kevin Enderby49b4f532014-07-28 23:17:38 +000039RUN: llvm-nm -u %p/Inputs/macho-hello-g.macho-x86_64 \
40RUN: | FileCheck %s -check-prefix macho-u
David Majnemerc7d7c6f2014-10-31 05:07:00 +000041RUN: llvm-nm -S -a %p/Inputs/common.coff-i386 \
Rafael Espindolafb66ef02014-02-04 23:18:52 +000042RUN: | FileCheck %s -check-prefix COFF-COMMON
Rafael Espindolab4865d62014-04-03 00:19:35 +000043RUN: llvm-nm %p/Inputs/relocatable-with-section-address.elf-x86-64 \
Kevin Enderby6abc2e52014-05-09 23:57:49 +000044RUN: | FileCheck %s -check-prefix ELF-SEC-ADDR64
Rafael Espindola5091f932014-04-03 02:20:43 +000045RUN: llvm-nm %p/Inputs/thumb-symbols.elf.arm \
46RUN: | FileCheck %s -check-prefix ELF-THUMB
Kevin Enderby4fc2edb2014-06-23 20:27:53 +000047RUN: mkdir -p %t
48RUN: cd %t
49RUN: cp %p/Inputs/trivial-object-test.macho-i386 a.out
50RUN: llvm-nm | FileCheck %s -check-prefix A-OUT
Rafael Espindola5091f932014-04-03 02:20:43 +000051
Michael J. Spencer2d67ed82011-01-20 06:39:15 +000052
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000053COFF32: 00000000 d .data
54COFF32-NEXT: 00000000 t .text
55COFF32-NEXT: 00000000 d L_.str
Rafael Espindola4fb845f2015-05-22 13:17:31 +000056COFF32-NEXT: U _SomeOtherFunction
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000057COFF32-NEXT: 00000000 T _main
Rafael Espindola4fb845f2015-05-22 13:17:31 +000058COFF32-NEXT: U _puts
59
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000060COFF64: 00000000 d .data
61COFF64-NEXT: 00000000 t .text
62COFF64-NEXT: 00000000 r ??__Ex@@YAXXZ
63COFF64-NEXT: 00000000 d L.str
Rafael Espindola4fb845f2015-05-22 13:17:31 +000064COFF64-NEXT: U SomeOtherFunction
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000065COFF64-NEXT: 00000000 T main
Rafael Espindola4fb845f2015-05-22 13:17:31 +000066COFF64-NEXT: U puts
Michael J. Spencer2d67ed82011-01-20 06:39:15 +000067
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000068COFF-COMMON: 00000000 b .bss
69COFF-COMMON-NEXT: 00000000 d .data
70COFF-COMMON-NEXT: 00000000 d .drectve
71COFF-COMMON-NEXT: 00000000 n .file
72COFF-COMMON-NEXT: 00000000 r .rdata$zzz
73COFF-COMMON-NEXT: 00000000 t .text
74COFF-COMMON-NEXT: C _a
Rafael Espindolafb66ef02014-02-04 23:18:52 +000075
76
Rafael Espindola0d6b3472013-07-22 19:24:34 +000077ELF-NOT: U
Michael J. Spencer2d67ed82011-01-20 06:39:15 +000078ELF: U SomeOtherFunction
79ELF: 00000000 T main
80ELF: U puts
Danil Malyshevcbe72fc2011-11-29 17:40:10 +000081
Rafael Espindolaf7cfed42015-05-22 13:28:35 +000082FIXME: we should not print the size of undefined symbols.
83ELF-SIZE: 00000000 U SomeOtherFunction
84ELF-SIZE-NEXT: 00000000 00000024 T main
85ELF-SIZE-NEXT: 00000000 U puts
86
Kevin Enderby08e1bbd2014-07-24 23:31:52 +000087ELF-o: {{.*}}/trivial-object-test.elf-i386: U SomeOtherFunction
88ELF-o: {{.*}}/trivial-object-test.elf-i386: 00000000 T main
89ELF-o: {{.*}}/trivial-object-test.elf-i386: U puts
90
Kevin Enderby49b4f532014-07-28 23:17:38 +000091ELF-u: U SomeOtherFunction
92ELF-u: U puts
93
Kevin Enderby6abc2e52014-05-09 23:57:49 +000094ELF64: U SomeOtherFunction
95ELF64: 0000000000000000 T main
96ELF64: U puts
Danil Malyshevcbe72fc2011-11-29 17:40:10 +000097
Kevin Enderby6abc2e52014-05-09 23:57:49 +000098WEAK-ELF64: w f1
99WEAK-ELF64: 0000000000000000 W f2
100WEAK-ELF64: v x1
101WEAK-ELF64: 0000000000000000 V x2
102
103ABSOLUTE-ELF64: 0000000000000123 a a1
104ABSOLUTE-ELF64: 0000000000000123 A a2
Rafael Espindola02eac9a2014-02-05 04:36:47 +0000105
Kevin Enderby1b985af2014-05-20 23:04:47 +0000106macho: U _SomeOtherFunction
Rafael Espindolaa1356322013-11-02 05:03:24 +0000107macho: 00000000 T _main
Kevin Enderby1b985af2014-05-20 23:04:47 +0000108macho: U _puts
Danil Malyshevcbe72fc2011-11-29 17:40:10 +0000109
Kevin Enderbyacaaf902014-07-03 18:18:50 +0000110macho-U-NOT: U _SomeOtherFunction
111macho-U: 00000000 T _main
112macho-U-NOT: U _puts
113
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000114macho64: 0000000000000028 s L_.str
Kevin Enderby1b985af2014-05-20 23:04:47 +0000115macho64: U _SomeOtherFunction
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000116macho64: 0000000000000000 T _main
Kevin Enderby1b985af2014-05-20 23:04:47 +0000117macho64: U _puts
Rafael Espindolab4865d62014-04-03 00:19:35 +0000118
Kevin Enderby1e1b9922014-06-19 22:49:21 +0000119macho-tdb: 0000000000000030 s EH_frame0
120macho-tdb: 0000000000000070 b _b
121macho-tdb: 000000000000000c D _d
122macho-tdb: 0000000000000000 T _t
123macho-tdb: 0000000000000048 S _t.eh
Rafael Espindolab4865d62014-04-03 00:19:35 +0000124
Kevin Enderby0fd8aac2014-07-03 21:51:07 +0000125macho-j: EH_frame0
126macho-j: _b
127macho-j: _d
128macho-j: _t
129macho-j: _t.eh
130
Kevin Enderby25a614b2014-07-02 23:23:58 +0000131macho-r: 0000000000000048 S _t.eh
132macho-r-NEXT: 0000000000000000 T _t
133macho-r-NEXT: 000000000000000c D _d
134macho-r-NEXT: 0000000000000070 b _b
135macho-r-NEXT: 0000000000000030 s EH_frame0
136
Kevin Enderbyfe6ad972014-07-11 20:30:00 +0000137macho-s: 000000000000000c D _d
138macho-s-NOT: 0000000000000048 S _t.eh
139macho-s-NOT: 0000000000000000 T _t
140macho-s-NOT: 0000000000000070 b _b
141macho-s-NOT: 0000000000000030 s EH_frame0
142
Kevin Enderby77b968e2014-07-16 17:38:26 +0000143macho-x: 0000000000000030 0e 05 0000 00000010 EH_frame0
144macho-x: 0000000000000070 0e 03 0000 0000000d _b
145macho-x: 000000000000000c 0f 02 0000 00000004 _d
146macho-x: 0000000000000000 0f 01 0000 00000001 _t
147macho-x: 0000000000000048 0f 05 0000 00000007 _t.eh
148
Kevin Enderby08e1bbd2014-07-24 23:31:52 +0000149
150macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000030 s EH_frame0
151macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000070 b _b
152macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 000000000000000c D _d
153macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000000 T _t
154macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000048 S _t.eh
155
Kevin Enderby407cc212014-07-17 22:47:16 +0000156macho-pa: 0000000000000000 - 00 0000 SO /Volumes/SandBox/
157macho-pa: 0000000000000000 - 00 0000 SO hello.c
158macho-pa: 0000000053c8408d - 03 0001 OSO /Volumes/SandBox/hello.o
159macho-pa: 0000000100000f30 - 01 0000 BNSYM
160macho-pa: 0000000100000f30 - 01 0000 FUN _main
161macho-pa: 000000000000003b - 00 0000 FUN
162macho-pa: 000000000000003b - 01 0000 ENSYM
163macho-pa: 0000000000000000 - 01 0000 SO
164macho-pa: 0000000100000000 T __mh_execute_header
165macho-pa: 0000000100000f30 T _main
166macho-pa: U _printf
167macho-pa: U dyld_stub_binder
168
Kevin Enderby49b4f532014-07-28 23:17:38 +0000169macho-u: _printf
170macho-u: dyld_stub_binder
171
Rafael Espindolab4865d62014-04-03 00:19:35 +0000172Test that nm uses addresses even with ELF .o files.
Kevin Enderby6abc2e52014-05-09 23:57:49 +0000173ELF-SEC-ADDR64: 0000000000000058 D a
174ELF-SEC-ADDR64-NEXT: 000000000000005c D b
175ELF-SEC-ADDR64-NEXT: 0000000000000040 T f
176ELF-SEC-ADDR64-NEXT: 0000000000000050 T g
177ELF-SEC-ADDR64-NEXT: 0000000000000060 D p
Rafael Espindola5091f932014-04-03 02:20:43 +0000178
179
180Test that we drop the thumb bit only from function addresses.
181ELF-THUMB: 00000000 t f
182ELF-THUMB: 00000003 t g
Kevin Enderby4fc2edb2014-06-23 20:27:53 +0000183
184A-OUT: U _SomeOtherFunction
185A-OUT: 00000000 T _main
186A-OUT: U _puts