Correctly compute the size of common symbols in COFF.
[oota-llvm.git] / test / Object / nm-trivial-object.test
1 RUN: yaml2obj %p/Inputs/COFF/i386.yaml | llvm-nm - \
2 RUN:         | FileCheck %s -check-prefix COFF
3 RUN: yaml2obj %p/Inputs/COFF/x86-64.yaml | llvm-nm - \
4 RUN:         | FileCheck %s -check-prefix COFF
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 %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 REQUIRES: shell
50
51
52 COFF: 00000000 d .data
53 COFF: 00000000 t .text
54 COFF: 00000000 d L{{_?}}.str
55 COFF:          U {{_?}}SomeOtherFunction
56 COFF: 00000000 T {{_?}}main
57 COFF:          U {{_?}}puts
58
59 COFF-COMMON: 00000000 00000000 b .bss
60 COFF-COMMON-NEXT: 00000000 00000000 d .data
61 COFF-COMMON-NEXT: 00000000 00000014 d .drectve
62 COFF-COMMON-NEXT: 00000000 00000000 n .file
63 COFF-COMMON-NEXT: 00000000 00000014 r .rdata$zzz
64 COFF-COMMON-NEXT: 00000000 00000000 t .text
65 COFF-COMMON-NEXT:          00000004 C _a
66
67
68 ELF-NOT:      U
69 ELF:          U SomeOtherFunction
70 ELF: 00000000 T main
71 ELF:          U puts
72
73 ELF-o: {{.*}}/trivial-object-test.elf-i386:          U SomeOtherFunction
74 ELF-o: {{.*}}/trivial-object-test.elf-i386: 00000000 T main
75 ELF-o: {{.*}}/trivial-object-test.elf-i386:          U puts
76
77 ELF-u:          U SomeOtherFunction
78 ELF-u:          U puts
79
80 ELF64:                  U SomeOtherFunction
81 ELF64: 0000000000000000 T main
82 ELF64:                  U puts
83
84 WEAK-ELF64:                  w f1
85 WEAK-ELF64: 0000000000000000 W f2
86 WEAK-ELF64:                  v x1
87 WEAK-ELF64: 0000000000000000 V x2
88
89 ABSOLUTE-ELF64: 0000000000000123 a a1
90 ABSOLUTE-ELF64: 0000000000000123 A a2
91
92 macho:          U _SomeOtherFunction
93 macho: 00000000 T _main
94 macho:          U _puts
95
96 macho-U-NOT:          U _SomeOtherFunction
97 macho-U: 00000000 T _main
98 macho-U-NOT:          U _puts
99
100 macho64: 0000000000000028 s L_.str
101 macho64:                  U _SomeOtherFunction
102 macho64: 0000000000000000 T _main
103 macho64:                  U _puts
104
105 macho-tdb: 0000000000000030 s EH_frame0
106 macho-tdb: 0000000000000070 b _b
107 macho-tdb: 000000000000000c D _d
108 macho-tdb: 0000000000000000 T _t
109 macho-tdb: 0000000000000048 S _t.eh
110
111 macho-j: EH_frame0
112 macho-j: _b
113 macho-j: _d
114 macho-j: _t
115 macho-j: _t.eh
116
117 macho-r: 0000000000000048 S _t.eh
118 macho-r-NEXT: 0000000000000000 T _t
119 macho-r-NEXT: 000000000000000c D _d
120 macho-r-NEXT: 0000000000000070 b _b
121 macho-r-NEXT: 0000000000000030 s EH_frame0
122
123 macho-s: 000000000000000c D _d
124 macho-s-NOT: 0000000000000048 S _t.eh
125 macho-s-NOT: 0000000000000000 T _t
126 macho-s-NOT: 0000000000000070 b _b
127 macho-s-NOT: 0000000000000030 s EH_frame0
128
129 macho-x: 0000000000000030 0e 05 0000 00000010 EH_frame0
130 macho-x: 0000000000000070 0e 03 0000 0000000d _b
131 macho-x: 000000000000000c 0f 02 0000 00000004 _d
132 macho-x: 0000000000000000 0f 01 0000 00000001 _t
133 macho-x: 0000000000000048 0f 05 0000 00000007 _t.eh
134
135
136 macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000030 s EH_frame0
137 macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000070 b _b
138 macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 000000000000000c D _d
139 macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000000 T _t
140 macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000048 S _t.eh
141
142 macho-pa: 0000000000000000 - 00 0000    SO /Volumes/SandBox/
143 macho-pa: 0000000000000000 - 00 0000    SO hello.c
144 macho-pa: 0000000053c8408d - 03 0001   OSO /Volumes/SandBox/hello.o
145 macho-pa: 0000000100000f30 - 01 0000 BNSYM 
146 macho-pa: 0000000100000f30 - 01 0000   FUN _main
147 macho-pa: 000000000000003b - 00 0000   FUN 
148 macho-pa: 000000000000003b - 01 0000 ENSYM 
149 macho-pa: 0000000000000000 - 01 0000    SO 
150 macho-pa: 0000000100000000 T __mh_execute_header
151 macho-pa: 0000000100000f30 T _main
152 macho-pa:                  U _printf
153 macho-pa:                  U dyld_stub_binder
154
155 macho-u: _printf
156 macho-u: dyld_stub_binder
157
158 Test that nm uses addresses even with ELF .o files.
159 ELF-SEC-ADDR64:      0000000000000058 D a
160 ELF-SEC-ADDR64-NEXT: 000000000000005c D b
161 ELF-SEC-ADDR64-NEXT: 0000000000000040 T f
162 ELF-SEC-ADDR64-NEXT: 0000000000000050 T g
163 ELF-SEC-ADDR64-NEXT: 0000000000000060 D p
164
165
166 Test that we drop the thumb bit only from function addresses.
167 ELF-THUMB: 00000000 t f
168 ELF-THUMB: 00000003 t g
169
170 A-OUT:          U _SomeOtherFunction
171 A-OUT: 00000000 T _main
172 A-OUT:          U _puts