2013-07-23 18:47:01 +08:00
|
|
|
RUN: rm -f %t.a
|
2015-07-14 04:38:09 +08:00
|
|
|
RUN: llvm-ar rcsU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
|
2014-07-09 07:47:31 +08:00
|
|
|
RUN: llvm-nm -M %t.a | FileCheck %s
|
2013-07-23 18:47:01 +08:00
|
|
|
|
2018-10-11 05:07:02 +08:00
|
|
|
RUN: rm -f %t.a
|
|
|
|
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
|
|
|
|
RUN: llvm-nm -M %t.a | FileCheck %s
|
|
|
|
RUXX: grep SYM64 %t.a
|
|
|
|
|
2013-07-23 18:47:01 +08:00
|
|
|
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
|
|
|
|
|
2015-07-23 03:34:26 +08:00
|
|
|
|
|
|
|
RUN: rm -f %t.a
|
2015-07-23 06:09:44 +08:00
|
|
|
RUN: llvm-ar --format=gnu rcT %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
|
2015-07-23 03:34:26 +08:00
|
|
|
RUN: llvm-nm -M %t.a | FileCheck --check-prefix=THIN %s
|
|
|
|
|
|
|
|
THIN: Archive map
|
|
|
|
THIN-NEXT: main in {{.*}}/Inputs/trivial-object-test.elf-x86-64
|
|
|
|
THIN-NEXT: foo in {{.*}}/Inputs/trivial-object-test2.elf-x86-64
|
|
|
|
THIN-NEXT: main in {{.*}}/Inputs/trivial-object-test2.elf-x86-64
|
|
|
|
|
|
|
|
|
2013-07-23 18:47:01 +08:00
|
|
|
CHECK: trivial-object-test.elf-x86-64:
|
2014-05-10 07:57:49 +08:00
|
|
|
CHECK-NEXT: U SomeOtherFunction
|
|
|
|
CHECK-NEXT: 0000000000000000 T main
|
|
|
|
CHECK-NEXT: U puts
|
2014-06-21 05:29:27 +08:00
|
|
|
|
|
|
|
CHECK: trivial-object-test2.elf-x86-64:
|
2014-05-10 07:57:49 +08:00
|
|
|
CHECK-NEXT: 0000000000000000 t bar
|
|
|
|
CHECK-NEXT: 0000000000000006 T foo
|
|
|
|
CHECK-NEXT: 0000000000000016 T main
|
2013-07-29 20:40:31 +08:00
|
|
|
|
|
|
|
RUN: rm -f %t.a
|
2015-07-14 04:38:09 +08:00
|
|
|
RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
|
2014-07-09 07:47:31 +08:00
|
|
|
RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP
|
2013-07-29 20:40:31 +08:00
|
|
|
|
|
|
|
NOMAP-NOT: Archive map
|
|
|
|
|
|
|
|
RUN: llvm-ar s %t.a
|
2014-07-09 07:47:31 +08:00
|
|
|
RUN: llvm-nm -M %t.a | FileCheck %s
|
2013-07-29 20:40:31 +08:00
|
|
|
|
|
|
|
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
|
2014-07-09 07:47:31 +08:00
|
|
|
RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT
|
2013-07-29 20:40:31 +08:00
|
|
|
|
|
|
|
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:
|
2014-05-10 07:57:49 +08:00
|
|
|
CORRUPT-NEXT: U SomeOtherFunction
|
|
|
|
CORRUPT-NEXT: 0000000000000000 T main
|
|
|
|
CORRUPT-NEXT: U puts
|
2014-06-21 05:29:27 +08:00
|
|
|
|
|
|
|
CORRUPT: trivial-object-test2.elf-x86-64:
|
2014-05-10 07:57:49 +08:00
|
|
|
CORRUPT-NEXT: 0000000000000000 t bar
|
|
|
|
CORRUPT-NEXT: 0000000000000006 T foo
|
|
|
|
CORRUPT-NEXT: 0000000000000016 T main
|
2013-07-29 20:40:31 +08:00
|
|
|
|
|
|
|
check that the we *don't* update the symbol table.
|
|
|
|
RUN: llvm-ar s %t.a
|
2014-07-09 07:47:31 +08:00
|
|
|
RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT
|
2013-08-29 00:22:16 +08:00
|
|
|
|
|
|
|
repeate the test with llvm-ranlib
|
|
|
|
|
|
|
|
RUN: rm -f %t.a
|
2015-07-14 04:38:09 +08:00
|
|
|
RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
|
2014-07-09 07:47:31 +08:00
|
|
|
RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP
|
2013-08-29 00:22:16 +08:00
|
|
|
|
|
|
|
RUN: llvm-ranlib %t.a
|
2014-07-09 07:47:31 +08:00
|
|
|
RUN: llvm-nm -M %t.a | FileCheck %s
|
2014-07-09 06:10:02 +08:00
|
|
|
|
2014-07-09 07:47:31 +08:00
|
|
|
RUN: llvm-nm -M %p/Inputs/macho-archive-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
|
2014-11-12 09:37:45 +08:00
|
|
|
RUN: llvm-nm -M %p/Inputs/macho-archive-unsorted-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
|
2014-07-09 06:10:02 +08:00
|
|
|
|
|
|
|
BSD-MachO: Archive map
|
|
|
|
BSD-MachO: _bar in bar.o
|
|
|
|
BSD-MachO: _foo in foo.o
|
2015-07-09 23:56:23 +08:00
|
|
|
|
|
|
|
RUN: rm -f %t.a
|
2015-07-14 04:38:09 +08:00
|
|
|
RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test2.macho-x86-64
|
2015-07-09 23:56:23 +08:00
|
|
|
RUN: llvm-nm -M %t.a | FileCheck --check-prefix=MACHO %s
|
|
|
|
|
2018-10-11 05:07:02 +08:00
|
|
|
RUN: rm -f %t.a
|
|
|
|
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
|
|
|
|
RUN: llvm-nm -M %t.a | FileCheck --check-prefix=MACHO %s
|
|
|
|
RUN: grep '__\.SYMDEF_64' %t.a
|
|
|
|
|
2015-07-09 23:56:23 +08:00
|
|
|
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
|
2015-10-26 21:40:03 +08:00
|
|
|
MACHO-NOT: {{^}}bar
|
2015-07-09 23:56:23 +08:00
|
|
|
|
|
|
|
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
|
2015-07-10 03:48:06 +08:00
|
|
|
|
2016-06-18 06:16:06 +08:00
|
|
|
RUN: llvm-nm -M %p/Inputs/macho-toc64-archive-x86_64.a | FileCheck --check-prefix=MACHO-TOC64 %s
|
|
|
|
|
|
|
|
MACHO-TOC64: Archive map
|
|
|
|
MACHO-TOC64-NEXT: _test in test.o
|
|
|
|
MACHO-TOC64-NEXT: _test in xtest.o
|
|
|
|
|
2015-08-28 15:40:30 +08:00
|
|
|
RUN: rm -f %t.a
|
|
|
|
RUN: llvm-ar --format=gnu rcsU %t.a %p/Inputs/coff-short-import-code %p/Inputs/coff-short-import-data
|
|
|
|
RUN: llvm-nm -M %t.a | FileCheck --check-prefix=COFF-SHORT-IMPORT %s
|
|
|
|
|
|
|
|
COFF-SHORT-IMPORT: Archive map
|
|
|
|
COFF-SHORT-IMPORT-NEXT: __imp__foo in coff-short-import-code
|
2015-09-01 14:01:53 +08:00
|
|
|
COFF-SHORT-IMPORT-NEXT: _foo in coff-short-import-code
|
|
|
|
COFF-SHORT-IMPORT-NEXT: __imp__bar in coff-short-import-data
|
|
|
|
COFF-SHORT-IMPORT-NOT: _bar in coff-short-import-data
|
2015-08-28 15:40:30 +08:00
|
|
|
|
2017-09-23 02:36:00 +08:00
|
|
|
Test that we pad the symbol table so that it ends in a multiple of 8 bytes:
|
2015-07-10 03:48:06 +08:00
|
|
|
8 + 60 + 36 == 104
|
|
|
|
RUN: rm -f %t.a
|
2015-07-14 04:38:09 +08:00
|
|
|
RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64
|
2015-07-10 03:48:06 +08:00
|
|
|
RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN %s < %t.a
|
|
|
|
MACHO-SYMTAB-ALIGN: !<arch>
|
|
|
|
MACHO-SYMTAB-ALIGN-NEXT: #1/12 {{..........}} 0 0 0 36 `
|
2017-09-23 02:16:13 +08:00
|
|
|
|
2017-09-23 02:36:00 +08:00
|
|
|
Test that we pad the symbol table so that it ends in a multiple of 8 bytes:
|
|
|
|
8 + 60 + 52 == 120
|
|
|
|
RUN: rm -f %t.a
|
|
|
|
RUN: llvm-ar --format=bsd rcsD %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test.macho-x86-64
|
|
|
|
RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN2 %s < %t.a
|
|
|
|
MACHO-SYMTAB-ALIGN2: !<arch>
|
|
|
|
MACHO-SYMTAB-ALIGN2-NEXT: #1/12 0 0 0 0 52 `
|
|
|
|
|
2017-09-23 02:16:13 +08:00
|
|
|
With a gnu symbol table we only align to two
|
|
|
|
8 + 60 + 14 = 82
|
|
|
|
RUN: rm -f %t.a
|
|
|
|
RUN: llvm-ar --format=gnu rcsD %t.a %p/Inputs/trivial-object-test.macho-x86-64
|
|
|
|
RUN: FileCheck --check-prefix=GNU-SYMTAB-ALIGN %s < %t.a
|
|
|
|
GNU-SYMTAB-ALIGN: !<arch>
|
|
|
|
GNU-SYMTAB-ALIGN-NEXT: / 0 0 0 0 14 `
|
2018-10-11 05:07:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
** Test the behavior of an empty archive:
|
|
|
|
|
|
|
|
No symbol table emitted for GNU archives
|
|
|
|
RUN: rm -f %t.a
|
|
|
|
RUN: llvm-ar rcs --format=gnu %t.a
|
|
|
|
RUN: not grep -q '/ ' %t.a
|
|
|
|
|
|
|
|
No symbol table for BSD archives
|
|
|
|
RUN: rm -f %t.a
|
|
|
|
RUN: llvm-ar rcs --format=bsd %t.a
|
|
|
|
RUN: not grep -q '__\.SYMDEF' %t.a
|
|
|
|
|
|
|
|
And we do emit a symbol table for DARWIN archives
|
|
|
|
RUN: rm -f %t.a
|
|
|
|
RUN: llvm-ar rcs --format=darwin %t.a
|
|
|
|
RUN: grep -q '__\.SYMDEF' %t.a
|