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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
|
# RUN: yaml2obj --docnum=1 %s -o %t.elf-x86-64
# RUN: yaml2obj --docnum=2 %s -o %t2.elf-x86-64
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Symbols:
- Name: main
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
- Name: SomeOtherFunction
Binding: STB_GLOBAL
- Name: puts
Binding: STB_GLOBAL
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Symbols:
- Name: bar
Type: STT_FUNC
Section: .text
- Name: foo
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Value: 0x0000000000000006
- Name: main
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Value: 0x0000000000000016
# RUN: rm -f %t.a
# RUN: llvm-ar rcsU %t.a %t.elf-x86-64 %t2.elf-x86-64
# RUN: llvm-nm --print-armap %t.a | FileCheck %s
# RUN: rm -f %t.a
# RUN: env SYM64_THRESHOLD=0 llvm-ar crTs %t.a %t.elf-x86-64 %t2.elf-x86-64
# RUN: llvm-nm --print-armap %t.a | FileCheck %s
# RUN: grep '/SYM64/' %t.a
# RUN: rm -f %t.a
# RUN: env SYM64_THRESHOLD=836 llvm-ar rcsU %t.a %t.elf-x86-64 %t2.elf-x86-64
# RUN: llvm-nm --print-armap %t.a | FileCheck %s
# RUN: grep '/SYM64/' %t.a
# RUN: rm -f %t.a
# RUN: env SYM64_THRESHOLD=837 llvm-ar rcsU %t.a %t.elf-x86-64 %t2.elf-x86-64
# RUN: llvm-nm --print-armap %t.a | FileCheck %s
# RUN: not grep '/SYM64/' %t.a
# CHECK: Archive map
# CHECK-NEXT: main in {{.*}}.elf-x86-64
# CHECK-NEXT: foo in {{.*}}2.elf-x86-64
# CHECK-NEXT: main in {{.*}}2.elf-x86-64
# CHECK-NOT: bar
# RUN: rm -f %t.a
# RUN: llvm-ar --format=gnu rcT %t.a %t.elf-x86-64 %t2.elf-x86-64
# RUN: llvm-nm --print-armap %t.a | FileCheck -DFILE=%/t.elf-x86-64 -DFILE2=%/t2.elf-x86-64 --check-prefix=THIN %s
# THIN: Archive map
# THIN-NEXT: main in [[FILE]]
# THIN-NEXT: foo in [[FILE2]]
# THIN-NEXT: main in [[FILE2]]
# CHECK: {{.*}}.elf-x86-64:
# CHECK-NEXT: U SomeOtherFunction
# CHECK-NEXT: 0000000000000000 T main
# CHECK-NEXT: U puts
# CHECK: {{.*}}2.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 %t.elf-x86-64 %t2.elf-x86-64
# RUN: llvm-nm --print-armap %t.a | FileCheck %s --check-prefix=NOMAP
# NOMAP-NOT: Archive map
# RUN: llvm-ar s %t.a
# RUN: llvm-nm --print-armap %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 --print-armap %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: {{.*}}.elf-x86-64:
# CORRUPT-NEXT: U SomeOtherFunction
# CORRUPT-NEXT: 0000000000000000 T main
# CORRUPT-NEXT: U puts
# CORRUPT: {{.*}}2.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 --print-armap %t.a | FileCheck %s --check-prefix=CORRUPT
## Repeat the test with llvm-ranlib.
# RUN: rm -f %t.a
# RUN: llvm-ar rcSU %t.a %t.elf-x86-64 %t2.elf-x86-64
# RUN: llvm-nm --print-armap %t.a | FileCheck %s --check-prefix=NOMAP
# RUN: llvm-ranlib %t.a
# RUN: llvm-nm --print-armap %t.a | FileCheck %s
# RUN: llvm-nm --print-armap %p/Inputs/macho-archive-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
# RUN: llvm-nm --print-armap %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 --print-armap %t.a | FileCheck --check-prefix=MACHO %s
# RUN: rm -f %t.a
# RUN: env SYM64_THRESHOLD=784 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 --print-armap %t.a | FileCheck --check-prefix=MACHO %s
# RUN: grep '__\.SYMDEF_64' %t.a
# RUN: rm -f %t.a
# RUN: env SYM64_THRESHOLD=785 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 --print-armap %t.a | FileCheck --check-prefix=MACHO %s
# RUN: not grep '__\.SYMDEF_64' %t.a
# 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
# RUN: llvm-nm --print-armap %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
# 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 --print-armap %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
# 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
## Test that we pad the symbol table so that it ends in a multiple of 8 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 `
## 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 `
## 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 `
## ** 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
|