aboutsummaryrefslogtreecommitdiff
path: root/test/Object/archive-symtab.test
blob: 6e4c76fb3768b41b7aa7e63321ca50935438bbe4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
RUN: rm -f %t.a
RUN: llvm-ar rcsU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
RUN: llvm-nm -M %t.a | FileCheck %s

CHECK: Archive map
CHECK-NEXT: main in trivial-object-test.elf-x86-64
CHECK-NEXT: foo in trivial-object-test2.elf-x86-64
CHECK-NEXT: main in trivial-object-test2.elf-x86-64
CHECK-NOT: bar

CHECK: trivial-object-test.elf-x86-64:
CHECK-NEXT:                  U SomeOtherFunction
CHECK-NEXT: 0000000000000000 T main
CHECK-NEXT:                  U puts

CHECK: trivial-object-test2.elf-x86-64:
CHECK-NEXT: 0000000000000000 t bar
CHECK-NEXT: 0000000000000006 T foo
CHECK-NEXT: 0000000000000016 T main

RUN: rm -f %t.a
RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP

NOMAP-NOT: Archive map

RUN: llvm-ar s %t.a
RUN: llvm-nm -M %t.a | FileCheck %s

check that the archive does have a corrupt symbol table.
RUN: rm -f %t.a
RUN: cp %p/Inputs/archive-test.a-corrupt-symbol-table %t.a
RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT

CORRUPT: Archive map
CORRUPT-NEXT: mbin in trivial-object-test.elf-x86-64
CORRUPT-NEXT: foo in trivial-object-test2.elf-x86-64
CORRUPT-NEXT: main in trivial-object-test2.elf-x86-64

CORRUPT: trivial-object-test.elf-x86-64:
CORRUPT-NEXT:                  U SomeOtherFunction
CORRUPT-NEXT: 0000000000000000 T main
CORRUPT-NEXT:                  U puts

CORRUPT: trivial-object-test2.elf-x86-64:
CORRUPT-NEXT: 0000000000000000 t bar
CORRUPT-NEXT: 0000000000000006 T foo
CORRUPT-NEXT: 0000000000000016 T main

check that the we *don't* update the symbol table.
RUN: llvm-ar s %t.a
RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT

repeate the test with llvm-ranlib

RUN: rm -f %t.a
RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP

RUN: llvm-ranlib %t.a
RUN: llvm-nm -M %t.a | FileCheck %s

RUN: llvm-nm -M %p/Inputs/macho-archive-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
RUN: llvm-nm -M %p/Inputs/macho-archive-unsorted-x86_64.a | FileCheck %s --check-prefix=BSD-MachO

BSD-MachO: Archive map
BSD-MachO: _bar in bar.o
BSD-MachO: _foo in foo.o

RUN: rm -f %t.a
RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test2.macho-x86-64
RUN: llvm-nm -M %t.a | FileCheck --check-prefix=MACHO %s

MACHO: Archive map
MACHO-NEXT: _main in trivial-object-test.macho-x86-64
MACHO-NEXT: _foo in trivial-object-test2.macho-x86-64
MACHO-NEXT: _main in trivial-object-test2.macho-x86-64
MACHO-NOT: bar

MACHO: trivial-object-test.macho-x86-64
MACHO-NEXT: 0000000000000028 s L_.str
MACHO-NEXT:                  U _SomeOtherFunction
MACHO-NEXT: 0000000000000000 T _main
MACHO-NEXT:                  U _puts

MACHO: trivial-object-test2.macho-x86-64
MACHO-NEXT: 0000000000000000 t _bar
MACHO-NEXT: 0000000000000001 T _foo
MACHO-NEXT: 0000000000000002 T _main

Test that we pad the symbol table so that it ends in a multiple of 4 bytes:
8 + 60 + 36 == 104
RUN: rm -f %t.a
RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64
RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN %s < %t.a
MACHO-SYMTAB-ALIGN: !<arch>
MACHO-SYMTAB-ALIGN-NEXT: #1/12           {{..........}}  0     0     0       36        `