2 RUN: llvm-ar rcsU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
3 RUN: llvm-nm -M %t.a | FileCheck %s
6 RUN: env SYM64_THRESHOLD=1 llvm-ar rcsU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
7 RUN: llvm-nm -M %t.a | FileCheck %s
11 CHECK-NEXT: main in trivial-object-test.elf-x86-64
12 CHECK-NEXT: foo in trivial-object-test2.elf-x86-64
13 CHECK-NEXT: main in trivial-object-test2.elf-x86-64
18 RUN: llvm-ar --format=gnu rcT %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
19 RUN: llvm-nm -M %t.a | FileCheck --check-prefix=THIN %s
22 THIN-NEXT: main in {{.*}}/Inputs/trivial-object-test.elf-x86-64
23 THIN-NEXT: foo in {{.*}}/Inputs/trivial-object-test2.elf-x86-64
24 THIN-NEXT: main in {{.*}}/Inputs/trivial-object-test2.elf-x86-64
27 CHECK: trivial-object-test.elf-x86-64:
28 CHECK-NEXT: U SomeOtherFunction
29 CHECK-NEXT: 0000000000000000 T main
32 CHECK: trivial-object-test2.elf-x86-64:
33 CHECK-NEXT: 0000000000000000 t bar
34 CHECK-NEXT: 0000000000000006 T foo
35 CHECK-NEXT: 0000000000000016 T main
38 RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
39 RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP
41 NOMAP-NOT: Archive map
44 RUN: llvm-nm -M %t.a | FileCheck %s
46 check that the archive does have a corrupt symbol table.
48 RUN: cp %p/Inputs/archive-test.a-corrupt-symbol-table %t.a
49 RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT
52 CORRUPT-NEXT: mbin in trivial-object-test.elf-x86-64
53 CORRUPT-NEXT: foo in trivial-object-test2.elf-x86-64
54 CORRUPT-NEXT: main in trivial-object-test2.elf-x86-64
56 CORRUPT: trivial-object-test.elf-x86-64:
57 CORRUPT-NEXT: U SomeOtherFunction
58 CORRUPT-NEXT: 0000000000000000 T main
61 CORRUPT: trivial-object-test2.elf-x86-64:
62 CORRUPT-NEXT: 0000000000000000 t bar
63 CORRUPT-NEXT: 0000000000000006 T foo
64 CORRUPT-NEXT: 0000000000000016 T main
66 check that the we *don't* update the symbol table.
68 RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT
70 repeate the test with llvm-ranlib
73 RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
74 RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP
77 RUN: llvm-nm -M %t.a | FileCheck %s
79 RUN: llvm-nm -M %p/Inputs/macho-archive-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
80 RUN: llvm-nm -M %p/Inputs/macho-archive-unsorted-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
82 BSD-MachO: Archive map
83 BSD-MachO: _bar in bar.o
84 BSD-MachO: _foo in foo.o
87 RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test2.macho-x86-64
88 RUN: llvm-nm -M %t.a | FileCheck --check-prefix=MACHO %s
91 RUN: env SYM64_THRESHOLD=1 llvm-ar --format=darwin rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test2.macho-x86-64
92 RUN: llvm-nm -M %t.a | FileCheck --check-prefix=MACHO %s
93 RUN: grep '__\.SYMDEF_64' %t.a
96 MACHO-NEXT: _main in trivial-object-test.macho-x86-64
97 MACHO-NEXT: _foo in trivial-object-test2.macho-x86-64
98 MACHO-NEXT: _main in trivial-object-test2.macho-x86-64
101 MACHO: trivial-object-test.macho-x86-64
102 MACHO-NEXT: 0000000000000028 s L_.str
103 MACHO-NEXT: U _SomeOtherFunction
104 MACHO-NEXT: 0000000000000000 T _main
107 MACHO: trivial-object-test2.macho-x86-64
108 MACHO-NEXT: 0000000000000000 t _bar
109 MACHO-NEXT: 0000000000000001 T _foo
110 MACHO-NEXT: 0000000000000002 T _main
112 RUN: llvm-nm -M %p/Inputs/macho-toc64-archive-x86_64.a | FileCheck --check-prefix=MACHO-TOC64 %s
114 MACHO-TOC64: Archive map
115 MACHO-TOC64-NEXT: _test in test.o
116 MACHO-TOC64-NEXT: _test in xtest.o
119 RUN: llvm-ar --format=gnu rcsU %t.a %p/Inputs/coff-short-import-code %p/Inputs/coff-short-import-data
120 RUN: llvm-nm -M %t.a | FileCheck --check-prefix=COFF-SHORT-IMPORT %s
122 COFF-SHORT-IMPORT: Archive map
123 COFF-SHORT-IMPORT-NEXT: __imp__foo in coff-short-import-code
124 COFF-SHORT-IMPORT-NEXT: _foo in coff-short-import-code
125 COFF-SHORT-IMPORT-NEXT: __imp__bar in coff-short-import-data
126 COFF-SHORT-IMPORT-NOT: _bar in coff-short-import-data
128 Test that we pad the symbol table so that it ends in a multiple of 8 bytes:
131 RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64
132 RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN %s < %t.a
133 MACHO-SYMTAB-ALIGN: !<arch>
134 MACHO-SYMTAB-ALIGN-NEXT: #1/12 {{..........}} 0 0 0 36 `
136 Test that we pad the symbol table so that it ends in a multiple of 8 bytes:
139 RUN: llvm-ar --format=bsd rcsD %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test.macho-x86-64
140 RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN2 %s < %t.a
141 MACHO-SYMTAB-ALIGN2: !<arch>
142 MACHO-SYMTAB-ALIGN2-NEXT: #1/12 0 0 0 0 52 `
144 With a gnu symbol table we only align to two
147 RUN: llvm-ar --format=gnu rcsD %t.a %p/Inputs/trivial-object-test.macho-x86-64
148 RUN: FileCheck --check-prefix=GNU-SYMTAB-ALIGN %s < %t.a
149 GNU-SYMTAB-ALIGN: !<arch>
150 GNU-SYMTAB-ALIGN-NEXT: / 0 0 0 0 14 `
153 ** Test the behavior of an empty archive:
155 No symbol table emitted for GNU archives
157 RUN: llvm-ar rcs --format=gnu %t.a
158 RUN: not grep -q '/ ' %t.a
160 No symbol table for BSD archives
162 RUN: llvm-ar rcs --format=bsd %t.a
163 RUN: not grep -q '__\.SYMDEF' %t.a
165 And we do emit a symbol table for DARWIN archives
167 RUN: llvm-ar rcs --format=darwin %t.a
168 RUN: grep -q '__\.SYMDEF' %t.a