1 # RUN: yaml2obj --docnum=1 %s -o %t.elf-x86-64
2 # RUN: yaml2obj --docnum=2 %s -o %t2.elf-x86-64
13 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
19 - Name: SomeOtherFunction
33 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
42 Value: 0x0000000000000006
47 Value: 0x0000000000000016
50 # RUN: llvm-ar rcsU %t.a %t.elf-x86-64 %t2.elf-x86-64
51 # RUN: llvm-nm --print-armap %t.a | FileCheck %s
54 # RUN: env SYM64_THRESHOLD=0 llvm-ar crTs %t.a %t.elf-x86-64 %t2.elf-x86-64
55 # RUN: llvm-nm --print-armap %t.a | FileCheck %s
56 # RUN: grep '/SYM64/' %t.a
59 # RUN: env SYM64_THRESHOLD=836 llvm-ar rcsU %t.a %t.elf-x86-64 %t2.elf-x86-64
60 # RUN: llvm-nm --print-armap %t.a | FileCheck %s
61 # RUN: grep '/SYM64/' %t.a
64 # RUN: env SYM64_THRESHOLD=837 llvm-ar rcsU %t.a %t.elf-x86-64 %t2.elf-x86-64
65 # RUN: llvm-nm --print-armap %t.a | FileCheck %s
66 # RUN: not grep '/SYM64/' %t.a
69 # RUN: llvm-ar rcsU --format=bigarchive %t.a %t.elf-x86-64 %t2.elf-x86-64
70 # RUN: llvm-nm --print-armap %t.a | FileCheck %s
73 # CHECK-NEXT: main in {{.*}}.elf-x86-64
74 # CHECK-NEXT: foo in {{.*}}2.elf-x86-64
75 # CHECK-NEXT: main in {{.*}}2.elf-x86-64
80 # RUN: llvm-ar --format=gnu rcT %t.a %t.elf-x86-64 %t2.elf-x86-64
81 # RUN: llvm-nm --print-armap %t.a | FileCheck -DFILE=%/t.elf-x86-64 -DFILE2=%/t2.elf-x86-64 --check-prefix=THIN %s
84 # THIN-NEXT: main in [[FILE]]
85 # THIN-NEXT: foo in [[FILE2]]
86 # THIN-NEXT: main in [[FILE2]]
89 # CHECK: {{.*}}.elf-x86-64:
90 # CHECK-NEXT: U SomeOtherFunction
91 # CHECK-NEXT: 0000000000000000 T main
94 # CHECK: {{.*}}2.elf-x86-64:
95 # CHECK-NEXT: 0000000000000000 t bar
96 # CHECK-NEXT: 0000000000000006 T foo
97 # CHECK-NEXT: 0000000000000016 T main
100 # RUN: llvm-ar rcSU %t.a %t.elf-x86-64 %t2.elf-x86-64
101 # RUN: llvm-nm --print-armap %t.a | FileCheck %s --check-prefix=NOMAP
103 # NOMAP-NOT: Archive map
105 # RUN: llvm-ar s %t.a
106 # RUN: llvm-nm --print-armap %t.a | FileCheck %s
108 ## Check that the archive does have a corrupt symbol table.
110 # RUN: cp %p/Inputs/archive-test.a-corrupt-symbol-table %t.a
111 # RUN: llvm-nm --print-armap %t.a | FileCheck %s --check-prefix=CORRUPT
113 # CORRUPT: Archive map
114 # CORRUPT-NEXT: mbin in trivial-object-test.elf-x86-64
115 # CORRUPT-NEXT: foo in trivial-object-test2.elf-x86-64
116 # CORRUPT-NEXT: main in trivial-object-test2.elf-x86-64
118 # CORRUPT: {{.*}}.elf-x86-64:
119 # CORRUPT-NEXT: U SomeOtherFunction
120 # CORRUPT-NEXT: 0000000000000000 T main
121 # CORRUPT-NEXT: U puts
123 # CORRUPT: {{.*}}2.elf-x86-64:
124 # CORRUPT-NEXT: 0000000000000000 t bar
125 # CORRUPT-NEXT: 0000000000000006 T foo
126 # CORRUPT-NEXT: 0000000000000016 T main
128 ## Check that the we *don't* update the symbol table.
129 # RUN: llvm-ar s %t.a
130 # RUN: llvm-nm --print-armap %t.a | FileCheck %s --check-prefix=CORRUPT
132 ## Repeat the test with llvm-ranlib.
135 # RUN: llvm-ar rcSU %t.a %t.elf-x86-64 %t2.elf-x86-64
136 # RUN: llvm-nm --print-armap %t.a | FileCheck %s --check-prefix=NOMAP
138 # RUN: llvm-ranlib %t.a
139 # RUN: llvm-nm --print-armap %t.a | FileCheck %s
141 # RUN: llvm-nm --print-armap %p/Inputs/macho-archive-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
142 # RUN: llvm-nm --print-armap %p/Inputs/macho-archive-unsorted-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
144 # BSD-MachO: Archive map
145 # BSD-MachO: _bar in bar.o
146 # BSD-MachO: _foo in foo.o
149 # RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test2.macho-x86-64
150 # RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=MACHO %s
153 # RUN: env SYM64_THRESHOLD=784 llvm-ar --format=darwin rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test2.macho-x86-64
154 # RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=MACHO %s
155 # RUN: grep '__\.SYMDEF_64' %t.a
158 # RUN: env SYM64_THRESHOLD=785 llvm-ar --format=darwin rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test2.macho-x86-64
159 # RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=MACHO %s
160 # RUN: not grep '__\.SYMDEF_64' %t.a
163 # MACHO-NEXT: _main in trivial-object-test.macho-x86-64
164 # MACHO-NEXT: _foo in trivial-object-test2.macho-x86-64
165 # MACHO-NEXT: _main in trivial-object-test2.macho-x86-64
166 # MACHO-NOT: {{^}}bar
168 # MACHO: trivial-object-test.macho-x86-64
169 # MACHO-NEXT: 0000000000000028 s L_.str
170 # MACHO-NEXT: U _SomeOtherFunction
171 # MACHO-NEXT: 0000000000000000 T _main
172 # MACHO-NEXT: U _puts
174 # MACHO: trivial-object-test2.macho-x86-64
175 # MACHO-NEXT: 0000000000000000 t _bar
176 # MACHO-NEXT: 0000000000000001 T _foo
177 # MACHO-NEXT: 0000000000000002 T _main
179 # RUN: llvm-nm --print-armap %p/Inputs/macho-toc64-archive-x86_64.a | FileCheck --check-prefix=MACHO-TOC64 %s
181 # MACHO-TOC64: Archive map
182 # MACHO-TOC64-NEXT: _test in test.o
183 # MACHO-TOC64-NEXT: _test in xtest.o
186 # RUN: llvm-ar --format=gnu rcsU %t.a %p/Inputs/coff-short-import-code %p/Inputs/coff-short-import-data
187 # RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=COFF-SHORT-IMPORT %s
189 # COFF-SHORT-IMPORT: Archive map
190 # COFF-SHORT-IMPORT-NEXT: __imp__foo in coff-short-import-code
191 # COFF-SHORT-IMPORT-NEXT: _foo in coff-short-import-code
192 # COFF-SHORT-IMPORT-NEXT: __imp__bar in coff-short-import-data
193 # COFF-SHORT-IMPORT-NOT: _bar in coff-short-import-data
195 ## Test that we pad the symbol table so that it ends in a multiple of 8 bytes:
196 ## 8 + 60 + 36 == 104
198 # RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64
199 # RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN %s < %t.a
200 # MACHO-SYMTAB-ALIGN: !<arch>
201 # MACHO-SYMTAB-ALIGN-NEXT: #1/12 {{..........}} 0 0 0 36 `
203 ## Test that we pad the symbol table so that it ends in a multiple of 8 bytes:
204 ## 8 + 60 + 52 == 120
206 # RUN: llvm-ar --format=bsd rcsD %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test.macho-x86-64
207 # RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN2 %s < %t.a
208 # MACHO-SYMTAB-ALIGN2: !<arch>
209 # MACHO-SYMTAB-ALIGN2-NEXT: #1/12 0 0 0 0 52 `
211 ## With a gnu symbol table we only align to two
214 # RUN: llvm-ar --format=gnu rcsD %t.a %p/Inputs/trivial-object-test.macho-x86-64
215 # RUN: FileCheck --check-prefix=GNU-SYMTAB-ALIGN %s < %t.a
216 # GNU-SYMTAB-ALIGN: !<arch>
217 # GNU-SYMTAB-ALIGN-NEXT: / 0 0 0 0 14 `
220 ## ** Test the behavior of an empty archive:
222 ## No symbol table emitted for GNU archives
224 # RUN: llvm-ar rcs --format=gnu %t.a
225 # RUN: not grep -q '/ ' %t.a
227 ## No symbol table for BSD archives
229 # RUN: llvm-ar rcs --format=bsd %t.a
230 # RUN: not grep -q '__\.SYMDEF' %t.a
232 ## And we do emit a symbol table for DARWIN archives
234 # RUN: llvm-ar rcs --format=darwin %t.a
235 # RUN: grep -q '__\.SYMDEF' %t.a