• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1RUN: rm -f %t.a
2RUN: llvm-ar rcsU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
3RUN: llvm-nm -M %t.a | FileCheck %s
4
5CHECK: Archive map
6CHECK-NEXT: main in trivial-object-test.elf-x86-64
7CHECK-NEXT: foo in trivial-object-test2.elf-x86-64
8CHECK-NEXT: main in trivial-object-test2.elf-x86-64
9CHECK-NOT: bar
10
11
12RUN: rm -f %t.a
13RUN: llvm-ar --format=gnu rcT %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
14RUN: llvm-nm -M %t.a | FileCheck --check-prefix=THIN %s
15
16THIN: Archive map
17THIN-NEXT: main in {{.*}}/Inputs/trivial-object-test.elf-x86-64
18THIN-NEXT: foo in {{.*}}/Inputs/trivial-object-test2.elf-x86-64
19THIN-NEXT: main in {{.*}}/Inputs/trivial-object-test2.elf-x86-64
20
21
22CHECK: trivial-object-test.elf-x86-64:
23CHECK-NEXT:                  U SomeOtherFunction
24CHECK-NEXT: 0000000000000000 T main
25CHECK-NEXT:                  U puts
26
27CHECK: trivial-object-test2.elf-x86-64:
28CHECK-NEXT: 0000000000000000 t bar
29CHECK-NEXT: 0000000000000006 T foo
30CHECK-NEXT: 0000000000000016 T main
31
32RUN: rm -f %t.a
33RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
34RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP
35
36NOMAP-NOT: Archive map
37
38RUN: llvm-ar s %t.a
39RUN: llvm-nm -M %t.a | FileCheck %s
40
41check that the archive does have a corrupt symbol table.
42RUN: rm -f %t.a
43RUN: cp %p/Inputs/archive-test.a-corrupt-symbol-table %t.a
44RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT
45
46CORRUPT: Archive map
47CORRUPT-NEXT: mbin in trivial-object-test.elf-x86-64
48CORRUPT-NEXT: foo in trivial-object-test2.elf-x86-64
49CORRUPT-NEXT: main in trivial-object-test2.elf-x86-64
50
51CORRUPT: trivial-object-test.elf-x86-64:
52CORRUPT-NEXT:                  U SomeOtherFunction
53CORRUPT-NEXT: 0000000000000000 T main
54CORRUPT-NEXT:                  U puts
55
56CORRUPT: trivial-object-test2.elf-x86-64:
57CORRUPT-NEXT: 0000000000000000 t bar
58CORRUPT-NEXT: 0000000000000006 T foo
59CORRUPT-NEXT: 0000000000000016 T main
60
61check that the we *don't* update the symbol table.
62RUN: llvm-ar s %t.a
63RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT
64
65repeate the test with llvm-ranlib
66
67RUN: rm -f %t.a
68RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
69RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP
70
71RUN: llvm-ranlib %t.a
72RUN: llvm-nm -M %t.a | FileCheck %s
73
74RUN: llvm-nm -M %p/Inputs/macho-archive-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
75RUN: llvm-nm -M %p/Inputs/macho-archive-unsorted-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
76
77BSD-MachO: Archive map
78BSD-MachO: _bar in bar.o
79BSD-MachO: _foo in foo.o
80
81RUN: rm -f %t.a
82RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test2.macho-x86-64
83RUN: llvm-nm -M %t.a | FileCheck --check-prefix=MACHO %s
84
85MACHO: Archive map
86MACHO-NEXT: _main in trivial-object-test.macho-x86-64
87MACHO-NEXT: _foo in trivial-object-test2.macho-x86-64
88MACHO-NEXT: _main in trivial-object-test2.macho-x86-64
89MACHO-NOT: {{^}}bar
90
91MACHO: trivial-object-test.macho-x86-64
92MACHO-NEXT: 0000000000000028 s L_.str
93MACHO-NEXT:                  U _SomeOtherFunction
94MACHO-NEXT: 0000000000000000 T _main
95MACHO-NEXT:                  U _puts
96
97MACHO: trivial-object-test2.macho-x86-64
98MACHO-NEXT: 0000000000000000 t _bar
99MACHO-NEXT: 0000000000000001 T _foo
100MACHO-NEXT: 0000000000000002 T _main
101
102RUN: llvm-nm -M %p/Inputs/macho-toc64-archive-x86_64.a | FileCheck --check-prefix=MACHO-TOC64 %s
103
104MACHO-TOC64: Archive map
105MACHO-TOC64-NEXT: _test in test.o
106MACHO-TOC64-NEXT: _test in xtest.o
107
108RUN: rm -f %t.a
109RUN: llvm-ar --format=gnu rcsU %t.a %p/Inputs/coff-short-import-code %p/Inputs/coff-short-import-data
110RUN: llvm-nm -M %t.a | FileCheck --check-prefix=COFF-SHORT-IMPORT %s
111
112COFF-SHORT-IMPORT:      Archive map
113COFF-SHORT-IMPORT-NEXT: __imp__foo in coff-short-import-code
114COFF-SHORT-IMPORT-NEXT: _foo in coff-short-import-code
115COFF-SHORT-IMPORT-NEXT: __imp__bar in coff-short-import-data
116COFF-SHORT-IMPORT-NOT:  _bar in coff-short-import-data
117
118Test that we pad the symbol table so that it ends in a multiple of 4 bytes:
1198 + 60 + 36 == 104
120RUN: rm -f %t.a
121RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64
122RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN %s < %t.a
123MACHO-SYMTAB-ALIGN: !<arch>
124MACHO-SYMTAB-ALIGN-NEXT: #1/12           {{..........}}  0     0     0       36        `
125