Make this test stricter. NFC.
[oota-llvm.git] / test / Object / nm-trivial-object.test
1 RUN: yaml2obj %p/Inputs/COFF/i386.yaml | llvm-nm -a -S - \
2 RUN:         | FileCheck %s -check-prefix COFF32
3 RUN: yaml2obj %p/Inputs/COFF/x86-64.yaml | llvm-nm -a -S - \
4 RUN:         | FileCheck %s -check-prefix COFF64
5 RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 \
6 RUN:         | FileCheck %s -check-prefix ELF
7 RUN: llvm-nm -o %p/Inputs/trivial-object-test.elf-i386 \
8 RUN:         | FileCheck %s -check-prefix ELF-o
9 RUN: llvm-nm -u %p/Inputs/trivial-object-test.elf-i386 \
10 RUN:         | FileCheck %s -check-prefix ELF-u
11 RUN: llvm-nm %p/Inputs/trivial-object-test.elf-x86-64 \
12 RUN:         | FileCheck %s -check-prefix ELF64
13 RUN: llvm-nm %p/Inputs/weak.elf-x86-64 \
14 RUN:         | FileCheck %s -check-prefix WEAK-ELF64
15 RUN: llvm-nm %p/Inputs/absolute.elf-x86-64 \
16 RUN:         | FileCheck %s -check-prefix ABSOLUTE-ELF64
17 RUN: llvm-nm %p/Inputs/trivial-object-test.macho-i386 \
18 RUN:         | FileCheck %s -check-prefix macho
19 RUN: llvm-nm -U %p/Inputs/trivial-object-test.macho-i386 \
20 RUN:         | FileCheck %s -check-prefix macho-U
21 RUN: llvm-nm %p/Inputs/trivial-object-test.macho-x86-64 \
22 RUN:         | FileCheck %s -check-prefix macho64
23 RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 \
24 RUN:         | FileCheck %s -check-prefix macho-tdb
25 RUN: llvm-nm -j %p/Inputs/macho-text-data-bss.macho-x86_64 \
26 RUN:         | FileCheck %s -check-prefix macho-j
27 RUN: llvm-nm -r %p/Inputs/macho-text-data-bss.macho-x86_64 \
28 RUN:         | FileCheck %s -check-prefix macho-r
29 RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 -s __DATA __data \
30 RUN:         | FileCheck %s -check-prefix macho-s
31 RUN: llvm-nm -x %p/Inputs/macho-text-data-bss.macho-x86_64 \
32 RUN:         | FileCheck %s -check-prefix macho-x
33 RUN: llvm-nm -o %p/Inputs/macho-text-data-bss.macho-x86_64 \
34 RUN:         | FileCheck %s -check-prefix macho-o
35 RUN: llvm-nm -p -a %p/Inputs/macho-hello-g.macho-x86_64 \
36 RUN:         | FileCheck %s -check-prefix macho-pa
37 RUN: llvm-nm -u %p/Inputs/macho-hello-g.macho-x86_64 \
38 RUN:         | FileCheck %s -check-prefix macho-u
39 RUN: llvm-nm -S -a %p/Inputs/common.coff-i386 \
40 RUN:         | FileCheck %s -check-prefix COFF-COMMON
41 RUN: llvm-nm %p/Inputs/relocatable-with-section-address.elf-x86-64 \
42 RUN:         | FileCheck %s -check-prefix ELF-SEC-ADDR64
43 RUN: llvm-nm %p/Inputs/thumb-symbols.elf.arm \
44 RUN:         | FileCheck %s -check-prefix ELF-THUMB
45 RUN: mkdir -p %t
46 RUN: cd %t
47 RUN: cp %p/Inputs/trivial-object-test.macho-i386 a.out
48 RUN: llvm-nm | FileCheck %s -check-prefix A-OUT
49
50
51 COFF32: 00000000 {{.*}} d .data
52 COFF32-NEXT: 00000000 {{.*}} t .text
53 COFF32-NEXT: 00000000 0000000d d L_.str
54 COFF32-NEXT:          U _SomeOtherFunction
55 COFF32-NEXT: 00000000 {{.*}} T _main
56 COFF32-NEXT:          U _puts
57
58 COFF64: 00000000 {{.*}} d .data
59 COFF64-NEXT: 00000000 {{.*}} t .text
60 COFF64-NEXT: 00000000 00000008 r ??__Ex@@YAXXZ
61 COFF64-NEXT: 00000000 0000000d d L.str
62 COFF64-NEXT:          U SomeOtherFunction
63 COFF64-NEXT: 00000000 {{.*}} T main
64 COFF64-NEXT:          U puts
65
66 COFF-COMMON: 00000000 00000000 b .bss
67 COFF-COMMON-NEXT: 00000000 00000000 d .data
68 COFF-COMMON-NEXT: 00000000 00000014 d .drectve
69 COFF-COMMON-NEXT: 00000000 00000000 n .file
70 COFF-COMMON-NEXT: 00000000 00000014 r .rdata$zzz
71 COFF-COMMON-NEXT: 00000000 00000000 t .text
72 COFF-COMMON-NEXT:          00000004 C _a
73
74
75 ELF-NOT:      U
76 ELF:          U SomeOtherFunction
77 ELF: 00000000 T main
78 ELF:          U puts
79
80 ELF-o: {{.*}}/trivial-object-test.elf-i386:          U SomeOtherFunction
81 ELF-o: {{.*}}/trivial-object-test.elf-i386: 00000000 T main
82 ELF-o: {{.*}}/trivial-object-test.elf-i386:          U puts
83
84 ELF-u:          U SomeOtherFunction
85 ELF-u:          U puts
86
87 ELF64:                  U SomeOtherFunction
88 ELF64: 0000000000000000 T main
89 ELF64:                  U puts
90
91 WEAK-ELF64:                  w f1
92 WEAK-ELF64: 0000000000000000 W f2
93 WEAK-ELF64:                  v x1
94 WEAK-ELF64: 0000000000000000 V x2
95
96 ABSOLUTE-ELF64: 0000000000000123 a a1
97 ABSOLUTE-ELF64: 0000000000000123 A a2
98
99 macho:          U _SomeOtherFunction
100 macho: 00000000 T _main
101 macho:          U _puts
102
103 macho-U-NOT:          U _SomeOtherFunction
104 macho-U: 00000000 T _main
105 macho-U-NOT:          U _puts
106
107 macho64: 0000000000000028 s L_.str
108 macho64:                  U _SomeOtherFunction
109 macho64: 0000000000000000 T _main
110 macho64:                  U _puts
111
112 macho-tdb: 0000000000000030 s EH_frame0
113 macho-tdb: 0000000000000070 b _b
114 macho-tdb: 000000000000000c D _d
115 macho-tdb: 0000000000000000 T _t
116 macho-tdb: 0000000000000048 S _t.eh
117
118 macho-j: EH_frame0
119 macho-j: _b
120 macho-j: _d
121 macho-j: _t
122 macho-j: _t.eh
123
124 macho-r: 0000000000000048 S _t.eh
125 macho-r-NEXT: 0000000000000000 T _t
126 macho-r-NEXT: 000000000000000c D _d
127 macho-r-NEXT: 0000000000000070 b _b
128 macho-r-NEXT: 0000000000000030 s EH_frame0
129
130 macho-s: 000000000000000c D _d
131 macho-s-NOT: 0000000000000048 S _t.eh
132 macho-s-NOT: 0000000000000000 T _t
133 macho-s-NOT: 0000000000000070 b _b
134 macho-s-NOT: 0000000000000030 s EH_frame0
135
136 macho-x: 0000000000000030 0e 05 0000 00000010 EH_frame0
137 macho-x: 0000000000000070 0e 03 0000 0000000d _b
138 macho-x: 000000000000000c 0f 02 0000 00000004 _d
139 macho-x: 0000000000000000 0f 01 0000 00000001 _t
140 macho-x: 0000000000000048 0f 05 0000 00000007 _t.eh
141
142
143 macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000030 s EH_frame0
144 macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000070 b _b
145 macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 000000000000000c D _d
146 macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000000 T _t
147 macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000048 S _t.eh
148
149 macho-pa: 0000000000000000 - 00 0000    SO /Volumes/SandBox/
150 macho-pa: 0000000000000000 - 00 0000    SO hello.c
151 macho-pa: 0000000053c8408d - 03 0001   OSO /Volumes/SandBox/hello.o
152 macho-pa: 0000000100000f30 - 01 0000 BNSYM 
153 macho-pa: 0000000100000f30 - 01 0000   FUN _main
154 macho-pa: 000000000000003b - 00 0000   FUN 
155 macho-pa: 000000000000003b - 01 0000 ENSYM 
156 macho-pa: 0000000000000000 - 01 0000    SO 
157 macho-pa: 0000000100000000 T __mh_execute_header
158 macho-pa: 0000000100000f30 T _main
159 macho-pa:                  U _printf
160 macho-pa:                  U dyld_stub_binder
161
162 macho-u: _printf
163 macho-u: dyld_stub_binder
164
165 Test that nm uses addresses even with ELF .o files.
166 ELF-SEC-ADDR64:      0000000000000058 D a
167 ELF-SEC-ADDR64-NEXT: 000000000000005c D b
168 ELF-SEC-ADDR64-NEXT: 0000000000000040 T f
169 ELF-SEC-ADDR64-NEXT: 0000000000000050 T g
170 ELF-SEC-ADDR64-NEXT: 0000000000000060 D p
171
172
173 Test that we drop the thumb bit only from function addresses.
174 ELF-THUMB: 00000000 t f
175 ELF-THUMB: 00000003 t g
176
177 A-OUT:          U _SomeOtherFunction
178 A-OUT: 00000000 T _main
179 A-OUT:          U _puts