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