blob: 8ba4ba0ae548159985ddc657804327c11b7e362c [file] [log] [blame]
Rafael Espindolace7f52d2013-07-23 10:47:01 +00001RUN: rm -f %t.a
Rafael Espindola6a8e86f2015-07-13 20:38:09 +00002RUN: llvm-ar rcsU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
Kevin Enderby8da4bd62014-07-08 23:47:31 +00003RUN: llvm-nm -M %t.a | FileCheck %s
Rafael Espindolace7f52d2013-07-23 10:47:01 +00004
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
Rafael Espindolabe9ab262015-07-22 19:34:26 +000011
12RUN: rm -f %t.a
13RUN: llvm-ar 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
Rafael Espindolace7f52d2013-07-23 10:47:01 +000022CHECK: trivial-object-test.elf-x86-64:
Kevin Enderby6abc2e52014-05-09 23:57:49 +000023CHECK-NEXT: U SomeOtherFunction
24CHECK-NEXT: 0000000000000000 T main
25CHECK-NEXT: U puts
Kevin Enderby26646102014-06-20 21:29:27 +000026
27CHECK: trivial-object-test2.elf-x86-64:
Kevin Enderby6abc2e52014-05-09 23:57:49 +000028CHECK-NEXT: 0000000000000000 t bar
29CHECK-NEXT: 0000000000000006 T foo
30CHECK-NEXT: 0000000000000016 T main
Rafael Espindolab6b5f52e2013-07-29 12:40:31 +000031
32RUN: rm -f %t.a
Rafael Espindola6a8e86f2015-07-13 20:38:09 +000033RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
Kevin Enderby8da4bd62014-07-08 23:47:31 +000034RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP
Rafael Espindolab6b5f52e2013-07-29 12:40:31 +000035
36NOMAP-NOT: Archive map
37
38RUN: llvm-ar s %t.a
Kevin Enderby8da4bd62014-07-08 23:47:31 +000039RUN: llvm-nm -M %t.a | FileCheck %s
Rafael Espindolab6b5f52e2013-07-29 12:40:31 +000040
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
Kevin Enderby8da4bd62014-07-08 23:47:31 +000044RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT
Rafael Espindolab6b5f52e2013-07-29 12:40:31 +000045
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:
Kevin Enderby6abc2e52014-05-09 23:57:49 +000052CORRUPT-NEXT: U SomeOtherFunction
53CORRUPT-NEXT: 0000000000000000 T main
54CORRUPT-NEXT: U puts
Kevin Enderby26646102014-06-20 21:29:27 +000055
56CORRUPT: trivial-object-test2.elf-x86-64:
Kevin Enderby6abc2e52014-05-09 23:57:49 +000057CORRUPT-NEXT: 0000000000000000 t bar
58CORRUPT-NEXT: 0000000000000006 T foo
59CORRUPT-NEXT: 0000000000000016 T main
Rafael Espindolab6b5f52e2013-07-29 12:40:31 +000060
61check that the we *don't* update the symbol table.
62RUN: llvm-ar s %t.a
Kevin Enderby8da4bd62014-07-08 23:47:31 +000063RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT
Rafael Espindola0c8a3522013-08-28 16:22:16 +000064
65repeate the test with llvm-ranlib
66
67RUN: rm -f %t.a
Rafael Espindola6a8e86f2015-07-13 20:38:09 +000068RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
Kevin Enderby8da4bd62014-07-08 23:47:31 +000069RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP
Rafael Espindola0c8a3522013-08-28 16:22:16 +000070
71RUN: llvm-ranlib %t.a
Kevin Enderby8da4bd62014-07-08 23:47:31 +000072RUN: llvm-nm -M %t.a | FileCheck %s
Kevin Enderby8c50dbb2014-07-08 22:10:02 +000073
Kevin Enderby8da4bd62014-07-08 23:47:31 +000074RUN: llvm-nm -M %p/Inputs/macho-archive-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
Nick Kledzikf44dbda2014-11-12 01:37:45 +000075RUN: llvm-nm -M %p/Inputs/macho-archive-unsorted-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
Kevin Enderby8c50dbb2014-07-08 22:10:02 +000076
77BSD-MachO: Archive map
78BSD-MachO: _bar in bar.o
79BSD-MachO: _foo in foo.o
Rafael Espindolac79bff62015-07-09 15:56:23 +000080
81RUN: rm -f %t.a
Rafael Espindola6a8e86f2015-07-13 20:38:09 +000082RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test2.macho-x86-64
Rafael Espindolac79bff62015-07-09 15:56:23 +000083RUN: 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
Rafael Espindola594e6762015-07-09 19:48:06 +0000101
102Test that we pad the symbol table so that it ends in a multiple of 4 bytes:
1038 + 60 + 36 == 104
104RUN: rm -f %t.a
Rafael Espindola6a8e86f2015-07-13 20:38:09 +0000105RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64
Rafael Espindola594e6762015-07-09 19:48:06 +0000106RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN %s < %t.a
107MACHO-SYMTAB-ALIGN: !<arch>
108MACHO-SYMTAB-ALIGN-NEXT: #1/12 {{..........}} 0 0 0 36 `