1 # RUN: yaml2obj -docnum=1 %s > %t.elf-x86-64
2 # RUN: yaml2obj -docnum=2 %s > %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 -M %t.a | FileCheck %s
54 # RUN: env SYM64_THRESHOLD=1 llvm-ar rcsU %t.a %t.elf-x86-64 %t2.elf-x86-64
55 # RUN: llvm-nm -M %t.a | FileCheck %s
56 # RUXX: grep SYM64 %t.a
59 # CHECK-NEXT: main in {{.*}}.elf-x86-64
60 # CHECK-NEXT: foo in {{.*}}2.elf-x86-64
61 # CHECK-NEXT: main in {{.*}}2.elf-x86-64
66 # RUN: llvm-ar --format=gnu rcT %t.a %t.elf-x86-64 %t2.elf-x86-64
67 # RUN: llvm-nm -M %t.a | FileCheck -DFILE=%/t.elf-x86-64 -DFILE2=%/t2.elf-x86-64 --check-prefix=THIN %s
70 # THIN-NEXT: main in [[FILE]]
71 # THIN-NEXT: foo in [[FILE2]]
72 # THIN-NEXT: main in [[FILE2]]
75 # CHECK: {{.*}}.elf-x86-64:
76 # CHECK-NEXT: U SomeOtherFunction
77 # CHECK-NEXT: 0000000000000000 T main
80 # CHECK: {{.*}}2.elf-x86-64:
81 # CHECK-NEXT: 0000000000000000 t bar
82 # CHECK-NEXT: 0000000000000006 T foo
83 # CHECK-NEXT: 0000000000000016 T main
86 # RUN: llvm-ar rcSU %t.a %t.elf-x86-64 %t2.elf-x86-64
87 # RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP
89 # NOMAP-NOT: Archive map
92 # RUN: llvm-nm -M %t.a | FileCheck %s
94 ## Check that the archive does have a corrupt symbol table.
96 # RUN: cp %p/Inputs/archive-test.a-corrupt-symbol-table %t.a
97 # RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT
99 # CORRUPT: Archive map
100 # CORRUPT-NEXT: mbin in trivial-object-test.elf-x86-64
101 # CORRUPT-NEXT: foo in trivial-object-test2.elf-x86-64
102 # CORRUPT-NEXT: main in trivial-object-test2.elf-x86-64
104 # CORRUPT: {{.*}}.elf-x86-64:
105 # CORRUPT-NEXT: U SomeOtherFunction
106 # CORRUPT-NEXT: 0000000000000000 T main
107 # CORRUPT-NEXT: U puts
109 # CORRUPT: {{.*}}2.elf-x86-64:
110 # CORRUPT-NEXT: 0000000000000000 t bar
111 # CORRUPT-NEXT: 0000000000000006 T foo
112 # CORRUPT-NEXT: 0000000000000016 T main
114 ## Check that the we *don't* update the symbol table.
115 # RUN: llvm-ar s %t.a
116 # RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT
118 ## Repeat the test with llvm-ranlib.
121 # RUN: llvm-ar rcSU %t.a %t.elf-x86-64 %t2.elf-x86-64
122 # RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP
124 # RUN: llvm-ranlib %t.a
125 # RUN: llvm-nm -M %t.a | FileCheck %s
127 # RUN: llvm-nm -M %p/Inputs/macho-archive-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
128 # RUN: llvm-nm -M %p/Inputs/macho-archive-unsorted-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
130 # BSD-MachO: Archive map
131 # BSD-MachO: _bar in bar.o
132 # BSD-MachO: _foo in foo.o
135 # RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test2.macho-x86-64
136 # RUN: llvm-nm -M %t.a | FileCheck --check-prefix=MACHO %s
139 # 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
140 # RUN: llvm-nm -M %t.a | FileCheck --check-prefix=MACHO %s
141 # RUN: grep '__\.SYMDEF_64' %t.a
144 # MACHO-NEXT: _main in trivial-object-test.macho-x86-64
145 # MACHO-NEXT: _foo in trivial-object-test2.macho-x86-64
146 # MACHO-NEXT: _main in trivial-object-test2.macho-x86-64
147 # MACHO-NOT: {{^}}bar
149 # MACHO: trivial-object-test.macho-x86-64
150 # MACHO-NEXT: 0000000000000028 s L_.str
151 # MACHO-NEXT: U _SomeOtherFunction
152 # MACHO-NEXT: 0000000000000000 T _main
153 # MACHO-NEXT: U _puts
155 # MACHO: trivial-object-test2.macho-x86-64
156 # MACHO-NEXT: 0000000000000000 t _bar
157 # MACHO-NEXT: 0000000000000001 T _foo
158 # MACHO-NEXT: 0000000000000002 T _main
160 # RUN: llvm-nm -M %p/Inputs/macho-toc64-archive-x86_64.a | FileCheck --check-prefix=MACHO-TOC64 %s
162 # MACHO-TOC64: Archive map
163 # MACHO-TOC64-NEXT: _test in test.o
164 # MACHO-TOC64-NEXT: _test in xtest.o
167 # RUN: llvm-ar --format=gnu rcsU %t.a %p/Inputs/coff-short-import-code %p/Inputs/coff-short-import-data
168 # RUN: llvm-nm -M %t.a | FileCheck --check-prefix=COFF-SHORT-IMPORT %s
170 # COFF-SHORT-IMPORT: Archive map
171 # COFF-SHORT-IMPORT-NEXT: __imp__foo in coff-short-import-code
172 # COFF-SHORT-IMPORT-NEXT: _foo in coff-short-import-code
173 # COFF-SHORT-IMPORT-NEXT: __imp__bar in coff-short-import-data
174 # COFF-SHORT-IMPORT-NOT: _bar in coff-short-import-data
176 ## Test that we pad the symbol table so that it ends in a multiple of 8 bytes:
177 ## 8 + 60 + 36 == 104
179 # RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64
180 # RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN %s < %t.a
181 # MACHO-SYMTAB-ALIGN: !<arch>
182 # MACHO-SYMTAB-ALIGN-NEXT: #1/12 {{..........}} 0 0 0 36 `
184 ## Test that we pad the symbol table so that it ends in a multiple of 8 bytes:
185 ## 8 + 60 + 52 == 120
187 # RUN: llvm-ar --format=bsd rcsD %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test.macho-x86-64
188 # RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN2 %s < %t.a
189 # MACHO-SYMTAB-ALIGN2: !<arch>
190 # MACHO-SYMTAB-ALIGN2-NEXT: #1/12 0 0 0 0 52 `
192 ## With a gnu symbol table we only align to two
195 # RUN: llvm-ar --format=gnu rcsD %t.a %p/Inputs/trivial-object-test.macho-x86-64
196 # RUN: FileCheck --check-prefix=GNU-SYMTAB-ALIGN %s < %t.a
197 # GNU-SYMTAB-ALIGN: !<arch>
198 # GNU-SYMTAB-ALIGN-NEXT: / 0 0 0 0 14 `
201 ## ** Test the behavior of an empty archive:
203 ## No symbol table emitted for GNU archives
205 # RUN: llvm-ar rcs --format=gnu %t.a
206 # RUN: not grep -q '/ ' %t.a
208 ## No symbol table for BSD archives
210 # RUN: llvm-ar rcs --format=bsd %t.a
211 # RUN: not grep -q '__\.SYMDEF' %t.a
213 ## And we do emit a symbol table for DARWIN archives
215 # RUN: llvm-ar rcs --format=darwin %t.a
216 # RUN: grep -q '__\.SYMDEF' %t.a