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 # CHECK-NEXT: main in {{.*}}.elf-x86-64
70 # CHECK-NEXT: foo in {{.*}}2.elf-x86-64
71 # CHECK-NEXT: main in {{.*}}2.elf-x86-64
76 # RUN: llvm-ar --format=gnu rcT %t.a %t.elf-x86-64 %t2.elf-x86-64
77 # RUN: llvm-nm --print-armap %t.a | FileCheck -DFILE=%/t.elf-x86-64 -DFILE2=%/t2.elf-x86-64 --check-prefix=THIN %s
80 # THIN-NEXT: main in [[FILE]]
81 # THIN-NEXT: foo in [[FILE2]]
82 # THIN-NEXT: main in [[FILE2]]
85 # CHECK: {{.*}}.elf-x86-64:
86 # CHECK-NEXT: U SomeOtherFunction
87 # CHECK-NEXT: 0000000000000000 T main
90 # CHECK: {{.*}}2.elf-x86-64:
91 # CHECK-NEXT: 0000000000000000 t bar
92 # CHECK-NEXT: 0000000000000006 T foo
93 # CHECK-NEXT: 0000000000000016 T main
96 # RUN: llvm-ar rcSU %t.a %t.elf-x86-64 %t2.elf-x86-64
97 # RUN: llvm-nm --print-armap %t.a | FileCheck %s --check-prefix=NOMAP
99 # NOMAP-NOT: Archive map
101 # RUN: llvm-ar s %t.a
102 # RUN: llvm-nm --print-armap %t.a | FileCheck %s
104 ## Check that the archive does have a corrupt symbol table.
106 # RUN: cp %p/Inputs/archive-test.a-corrupt-symbol-table %t.a
107 # RUN: llvm-nm --print-armap %t.a | FileCheck %s --check-prefix=CORRUPT
109 # CORRUPT: Archive map
110 # CORRUPT-NEXT: mbin in trivial-object-test.elf-x86-64
111 # CORRUPT-NEXT: foo in trivial-object-test2.elf-x86-64
112 # CORRUPT-NEXT: main in trivial-object-test2.elf-x86-64
114 # CORRUPT: {{.*}}.elf-x86-64:
115 # CORRUPT-NEXT: U SomeOtherFunction
116 # CORRUPT-NEXT: 0000000000000000 T main
117 # CORRUPT-NEXT: U puts
119 # CORRUPT: {{.*}}2.elf-x86-64:
120 # CORRUPT-NEXT: 0000000000000000 t bar
121 # CORRUPT-NEXT: 0000000000000006 T foo
122 # CORRUPT-NEXT: 0000000000000016 T main
124 ## Check that the we *don't* update the symbol table.
125 # RUN: llvm-ar s %t.a
126 # RUN: llvm-nm --print-armap %t.a | FileCheck %s --check-prefix=CORRUPT
128 ## Repeat the test with llvm-ranlib.
131 # RUN: llvm-ar rcSU %t.a %t.elf-x86-64 %t2.elf-x86-64
132 # RUN: llvm-nm --print-armap %t.a | FileCheck %s --check-prefix=NOMAP
134 # RUN: llvm-ranlib %t.a
135 # RUN: llvm-nm --print-armap %t.a | FileCheck %s
137 # RUN: llvm-nm --print-armap %p/Inputs/macho-archive-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
138 # RUN: llvm-nm --print-armap %p/Inputs/macho-archive-unsorted-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
140 # BSD-MachO: Archive map
141 # BSD-MachO: _bar in bar.o
142 # BSD-MachO: _foo in foo.o
145 # RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test2.macho-x86-64
146 # RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=MACHO %s
149 # 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
150 # RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=MACHO %s
151 # RUN: grep '__\.SYMDEF_64' %t.a
154 # 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
155 # RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=MACHO %s
156 # RUN: not grep '__\.SYMDEF_64' %t.a
159 # MACHO-NEXT: _main in trivial-object-test.macho-x86-64
160 # MACHO-NEXT: _foo in trivial-object-test2.macho-x86-64
161 # MACHO-NEXT: _main in trivial-object-test2.macho-x86-64
162 # MACHO-NOT: {{^}}bar
164 # MACHO: trivial-object-test.macho-x86-64
165 # MACHO-NEXT: 0000000000000028 s L_.str
166 # MACHO-NEXT: U _SomeOtherFunction
167 # MACHO-NEXT: 0000000000000000 T _main
168 # MACHO-NEXT: U _puts
170 # MACHO: trivial-object-test2.macho-x86-64
171 # MACHO-NEXT: 0000000000000000 t _bar
172 # MACHO-NEXT: 0000000000000001 T _foo
173 # MACHO-NEXT: 0000000000000002 T _main
175 # RUN: llvm-nm --print-armap %p/Inputs/macho-toc64-archive-x86_64.a | FileCheck --check-prefix=MACHO-TOC64 %s
177 # MACHO-TOC64: Archive map
178 # MACHO-TOC64-NEXT: _test in test.o
179 # MACHO-TOC64-NEXT: _test in xtest.o
182 # RUN: llvm-ar --format=gnu rcsU %t.a %p/Inputs/coff-short-import-code %p/Inputs/coff-short-import-data
183 # RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=COFF-SHORT-IMPORT %s
185 # COFF-SHORT-IMPORT: Archive map
186 # COFF-SHORT-IMPORT-NEXT: __imp__foo in coff-short-import-code
187 # COFF-SHORT-IMPORT-NEXT: _foo in coff-short-import-code
188 # COFF-SHORT-IMPORT-NEXT: __imp__bar in coff-short-import-data
189 # COFF-SHORT-IMPORT-NOT: _bar in coff-short-import-data
191 ## Test that we pad the symbol table so that it ends in a multiple of 8 bytes:
192 ## 8 + 60 + 36 == 104
194 # RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64
195 # RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN %s < %t.a
196 # MACHO-SYMTAB-ALIGN: !<arch>
197 # MACHO-SYMTAB-ALIGN-NEXT: #1/12 {{..........}} 0 0 0 36 `
199 ## Test that we pad the symbol table so that it ends in a multiple of 8 bytes:
200 ## 8 + 60 + 52 == 120
202 # RUN: llvm-ar --format=bsd rcsD %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test.macho-x86-64
203 # RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN2 %s < %t.a
204 # MACHO-SYMTAB-ALIGN2: !<arch>
205 # MACHO-SYMTAB-ALIGN2-NEXT: #1/12 0 0 0 0 52 `
207 ## With a gnu symbol table we only align to two
210 # RUN: llvm-ar --format=gnu rcsD %t.a %p/Inputs/trivial-object-test.macho-x86-64
211 # RUN: FileCheck --check-prefix=GNU-SYMTAB-ALIGN %s < %t.a
212 # GNU-SYMTAB-ALIGN: !<arch>
213 # GNU-SYMTAB-ALIGN-NEXT: / 0 0 0 0 14 `
216 ## ** Test the behavior of an empty archive:
218 ## No symbol table emitted for GNU archives
220 # RUN: llvm-ar rcs --format=gnu %t.a
221 # RUN: not grep -q '/ ' %t.a
223 ## No symbol table for BSD archives
225 # RUN: llvm-ar rcs --format=bsd %t.a
226 # RUN: not grep -q '__\.SYMDEF' %t.a
228 ## And we do emit a symbol table for DARWIN archives
230 # RUN: llvm-ar rcs --format=darwin %t.a
231 # RUN: grep -q '__\.SYMDEF' %t.a