Rafael Espindola | 26b10da | 2013-07-23 10:47:01 +0000 | [diff] [blame] | 1 | RUN: rm -f %t.a |
Rafael Espindola | 168b1be | 2015-07-13 20:38:09 +0000 | [diff] [blame] | 2 | RUN: llvm-ar rcsU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64 |
Kevin Enderby | e3108d3 | 2014-07-08 23:47:31 +0000 | [diff] [blame] | 3 | RUN: llvm-nm -M %t.a | FileCheck %s |
Rafael Espindola | 26b10da | 2013-07-23 10:47:01 +0000 | [diff] [blame] | 4 | |
James Y Knight | 742beb6 | 2018-10-10 21:07:02 +0000 | [diff] [blame] | 5 | RUN: rm -f %t.a |
| 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 |
| 8 | RUXX: grep SYM64 %t.a |
| 9 | |
Rafael Espindola | 26b10da | 2013-07-23 10:47:01 +0000 | [diff] [blame] | 10 | CHECK: Archive map |
| 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 |
| 14 | CHECK-NOT: bar |
| 15 | |
Rafael Espindola | 9db135a | 2015-07-22 19:34:26 +0000 | [diff] [blame] | 16 | |
| 17 | RUN: rm -f %t.a |
Rafael Espindola | 3b12bb7 | 2015-07-22 22:09:44 +0000 | [diff] [blame] | 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 |
Rafael Espindola | 9db135a | 2015-07-22 19:34:26 +0000 | [diff] [blame] | 19 | RUN: llvm-nm -M %t.a | FileCheck --check-prefix=THIN %s |
| 20 | |
| 21 | THIN: Archive map |
| 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 |
| 25 | |
| 26 | |
Rafael Espindola | 26b10da | 2013-07-23 10:47:01 +0000 | [diff] [blame] | 27 | CHECK: trivial-object-test.elf-x86-64: |
Kevin Enderby | ae41759 | 2014-05-09 23:57:49 +0000 | [diff] [blame] | 28 | CHECK-NEXT: U SomeOtherFunction |
| 29 | CHECK-NEXT: 0000000000000000 T main |
| 30 | CHECK-NEXT: U puts |
Kevin Enderby | efc4478 | 2014-06-20 21:29:27 +0000 | [diff] [blame] | 31 | |
| 32 | CHECK: trivial-object-test2.elf-x86-64: |
Kevin Enderby | ae41759 | 2014-05-09 23:57:49 +0000 | [diff] [blame] | 33 | CHECK-NEXT: 0000000000000000 t bar |
| 34 | CHECK-NEXT: 0000000000000006 T foo |
| 35 | CHECK-NEXT: 0000000000000016 T main |
Rafael Espindola | cf48cf2 | 2013-07-29 12:40:31 +0000 | [diff] [blame] | 36 | |
| 37 | RUN: rm -f %t.a |
Rafael Espindola | 168b1be | 2015-07-13 20:38:09 +0000 | [diff] [blame] | 38 | RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64 |
Kevin Enderby | e3108d3 | 2014-07-08 23:47:31 +0000 | [diff] [blame] | 39 | RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP |
Rafael Espindola | cf48cf2 | 2013-07-29 12:40:31 +0000 | [diff] [blame] | 40 | |
| 41 | NOMAP-NOT: Archive map |
| 42 | |
| 43 | RUN: llvm-ar s %t.a |
Kevin Enderby | e3108d3 | 2014-07-08 23:47:31 +0000 | [diff] [blame] | 44 | RUN: llvm-nm -M %t.a | FileCheck %s |
Rafael Espindola | cf48cf2 | 2013-07-29 12:40:31 +0000 | [diff] [blame] | 45 | |
| 46 | check that the archive does have a corrupt symbol table. |
| 47 | RUN: rm -f %t.a |
| 48 | RUN: cp %p/Inputs/archive-test.a-corrupt-symbol-table %t.a |
Kevin Enderby | e3108d3 | 2014-07-08 23:47:31 +0000 | [diff] [blame] | 49 | RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT |
Rafael Espindola | cf48cf2 | 2013-07-29 12:40:31 +0000 | [diff] [blame] | 50 | |
| 51 | CORRUPT: Archive map |
| 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 |
| 55 | |
| 56 | CORRUPT: trivial-object-test.elf-x86-64: |
Kevin Enderby | ae41759 | 2014-05-09 23:57:49 +0000 | [diff] [blame] | 57 | CORRUPT-NEXT: U SomeOtherFunction |
| 58 | CORRUPT-NEXT: 0000000000000000 T main |
| 59 | CORRUPT-NEXT: U puts |
Kevin Enderby | efc4478 | 2014-06-20 21:29:27 +0000 | [diff] [blame] | 60 | |
| 61 | CORRUPT: trivial-object-test2.elf-x86-64: |
Kevin Enderby | ae41759 | 2014-05-09 23:57:49 +0000 | [diff] [blame] | 62 | CORRUPT-NEXT: 0000000000000000 t bar |
| 63 | CORRUPT-NEXT: 0000000000000006 T foo |
| 64 | CORRUPT-NEXT: 0000000000000016 T main |
Rafael Espindola | cf48cf2 | 2013-07-29 12:40:31 +0000 | [diff] [blame] | 65 | |
| 66 | check that the we *don't* update the symbol table. |
| 67 | RUN: llvm-ar s %t.a |
Kevin Enderby | e3108d3 | 2014-07-08 23:47:31 +0000 | [diff] [blame] | 68 | RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT |
Rafael Espindola | aeb0f0c | 2013-08-28 16:22:16 +0000 | [diff] [blame] | 69 | |
| 70 | repeate the test with llvm-ranlib |
| 71 | |
| 72 | RUN: rm -f %t.a |
Rafael Espindola | 168b1be | 2015-07-13 20:38:09 +0000 | [diff] [blame] | 73 | RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64 |
Kevin Enderby | e3108d3 | 2014-07-08 23:47:31 +0000 | [diff] [blame] | 74 | RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP |
Rafael Espindola | aeb0f0c | 2013-08-28 16:22:16 +0000 | [diff] [blame] | 75 | |
| 76 | RUN: llvm-ranlib %t.a |
Kevin Enderby | e3108d3 | 2014-07-08 23:47:31 +0000 | [diff] [blame] | 77 | RUN: llvm-nm -M %t.a | FileCheck %s |
Kevin Enderby | d2ae115 | 2014-07-08 22:10:02 +0000 | [diff] [blame] | 78 | |
Kevin Enderby | e3108d3 | 2014-07-08 23:47:31 +0000 | [diff] [blame] | 79 | RUN: llvm-nm -M %p/Inputs/macho-archive-x86_64.a | FileCheck %s --check-prefix=BSD-MachO |
Nick Kledzik | 9abbcb7 | 2014-11-12 01:37:45 +0000 | [diff] [blame] | 80 | RUN: llvm-nm -M %p/Inputs/macho-archive-unsorted-x86_64.a | FileCheck %s --check-prefix=BSD-MachO |
Kevin Enderby | d2ae115 | 2014-07-08 22:10:02 +0000 | [diff] [blame] | 81 | |
| 82 | BSD-MachO: Archive map |
| 83 | BSD-MachO: _bar in bar.o |
| 84 | BSD-MachO: _foo in foo.o |
Rafael Espindola | a55816b | 2015-07-09 15:56:23 +0000 | [diff] [blame] | 85 | |
| 86 | RUN: rm -f %t.a |
Rafael Espindola | 168b1be | 2015-07-13 20:38:09 +0000 | [diff] [blame] | 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 |
Rafael Espindola | a55816b | 2015-07-09 15:56:23 +0000 | [diff] [blame] | 88 | RUN: llvm-nm -M %t.a | FileCheck --check-prefix=MACHO %s |
| 89 | |
James Y Knight | 742beb6 | 2018-10-10 21:07:02 +0000 | [diff] [blame] | 90 | RUN: rm -f %t.a |
| 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 |
| 94 | |
Rafael Espindola | a55816b | 2015-07-09 15:56:23 +0000 | [diff] [blame] | 95 | MACHO: Archive map |
| 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 |
Tim Northover | 3d79a79 | 2015-10-26 13:40:03 +0000 | [diff] [blame] | 99 | MACHO-NOT: {{^}}bar |
Rafael Espindola | a55816b | 2015-07-09 15:56:23 +0000 | [diff] [blame] | 100 | |
| 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 |
| 105 | MACHO-NEXT: U _puts |
| 106 | |
| 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 |
Rafael Espindola | 7255090 | 2015-07-09 19:48:06 +0000 | [diff] [blame] | 111 | |
Kevin Enderby | 68806ff | 2016-06-17 22:16:06 +0000 | [diff] [blame] | 112 | RUN: llvm-nm -M %p/Inputs/macho-toc64-archive-x86_64.a | FileCheck --check-prefix=MACHO-TOC64 %s |
| 113 | |
| 114 | MACHO-TOC64: Archive map |
| 115 | MACHO-TOC64-NEXT: _test in test.o |
| 116 | MACHO-TOC64-NEXT: _test in xtest.o |
| 117 | |
Rui Ueyama | 40e2251 | 2015-08-28 07:40:30 +0000 | [diff] [blame] | 118 | RUN: rm -f %t.a |
| 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 |
| 121 | |
| 122 | COFF-SHORT-IMPORT: Archive map |
Rui Ueyama | 40e2251 | 2015-08-28 07:40:30 +0000 | [diff] [blame] | 123 | COFF-SHORT-IMPORT-NEXT: __imp__foo in coff-short-import-code |
Rui Ueyama | 5c1fa7f | 2015-09-01 06:01:53 +0000 | [diff] [blame] | 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 |
Rui Ueyama | 40e2251 | 2015-08-28 07:40:30 +0000 | [diff] [blame] | 127 | |
Rafael Espindola | d3fa505 | 2017-09-22 18:36:00 +0000 | [diff] [blame] | 128 | Test that we pad the symbol table so that it ends in a multiple of 8 bytes: |
Rafael Espindola | 7255090 | 2015-07-09 19:48:06 +0000 | [diff] [blame] | 129 | 8 + 60 + 36 == 104 |
| 130 | RUN: rm -f %t.a |
Rafael Espindola | 168b1be | 2015-07-13 20:38:09 +0000 | [diff] [blame] | 131 | RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 |
Rafael Espindola | 7255090 | 2015-07-09 19:48:06 +0000 | [diff] [blame] | 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 ` |
Rafael Espindola | b4d4e8c | 2017-09-22 18:16:13 +0000 | [diff] [blame] | 135 | |
Rafael Espindola | d3fa505 | 2017-09-22 18:36:00 +0000 | [diff] [blame] | 136 | Test that we pad the symbol table so that it ends in a multiple of 8 bytes: |
| 137 | 8 + 60 + 52 == 120 |
| 138 | RUN: rm -f %t.a |
| 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 ` |
| 143 | |
Rafael Espindola | b4d4e8c | 2017-09-22 18:16:13 +0000 | [diff] [blame] | 144 | With a gnu symbol table we only align to two |
| 145 | 8 + 60 + 14 = 82 |
| 146 | RUN: rm -f %t.a |
| 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 ` |
James Y Knight | 742beb6 | 2018-10-10 21:07:02 +0000 | [diff] [blame] | 151 | |
| 152 | |
| 153 | ** Test the behavior of an empty archive: |
| 154 | |
| 155 | No symbol table emitted for GNU archives |
| 156 | RUN: rm -f %t.a |
| 157 | RUN: llvm-ar rcs --format=gnu %t.a |
| 158 | RUN: not grep -q '/ ' %t.a |
| 159 | |
| 160 | No symbol table for BSD archives |
| 161 | RUN: rm -f %t.a |
| 162 | RUN: llvm-ar rcs --format=bsd %t.a |
| 163 | RUN: not grep -q '__\.SYMDEF' %t.a |
| 164 | |
| 165 | And we do emit a symbol table for DARWIN archives |
| 166 | RUN: rm -f %t.a |
| 167 | RUN: llvm-ar rcs --format=darwin %t.a |
| 168 | RUN: grep -q '__\.SYMDEF' %t.a |