7 changes: 6 additions & 1 deletion lld/test/MachO/tlv-dylib.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libtlv.s -o %t/libtlv.o
# RUN: %lld -dylib -install_name @executable_path/libtlv.dylib \
# RUN: -lSystem -o %t/libtlv.dylib %t/libtlv.o
# RUN: llvm-objdump --exports-trie -d --no-show-raw-insn %t/libtlv.dylib | FileCheck %s --check-prefix=DYLIB
# RUN: llvm-objdump --macho --exports-trie --rebase %t/libtlv.dylib | \
# RUN: FileCheck %s --check-prefix=DYLIB
# DYLIB-DAG: _foo [per-thread]
# DYLIB-DAG: _bar [per-thread]
## Make sure we don't emit rebase opcodes for relocations in __thread_vars.
# DYLIB: Rebase table:
# DYLIB-NEXT: segment section address type
# DYLIB-EMPTY:

# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
# RUN: %lld -lSystem -L%t -ltlv %t/test.o -o %t/test
Expand Down
14 changes: 13 additions & 1 deletion lld/test/MachO/tlv.s
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# REQUIRES: x86
# RUN: mkdir -p %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o

# RUN: %lld -lSystem -o %t/test %t/test.o
# RUN: llvm-readobj --file-headers %t/test | FileCheck %s --check-prefix=HEADER
# RUN: llvm-objdump -D %t/test | FileCheck %s
# RUN: llvm-objdump -D --bind --rebase %t/test | FileCheck %s

# RUN: %lld -lSystem -pie -o %t/test %t/test.o
# RUN: llvm-readobj --file-headers %t/test | FileCheck %s --check-prefix=HEADER
# RUN: llvm-objdump -D --bind --rebase %t/test | FileCheck %s

# HEADER: MH_HAS_TLV_DESCRIPTORS

Expand Down Expand Up @@ -36,6 +41,13 @@
# CHECK-NEXT: 00 00
# CHECK-NEXT: 00 00

## Make sure we don't emit rebase opcodes for relocations in __thread_vars.
# CHECK: Rebase table:
# CHECK-NEXT: segment section address type
# CHECK-NEXT: Bind table:
# CHECK: __DATA __thread_vars 0x{{[0-9a-f]*}} pointer 0 libSystem __tlv_bootstrap
# CHECK: __DATA __thread_vars 0x{{[0-9a-f]*}} pointer 0 libSystem __tlv_bootstrap

.globl _main
_main:
mov _foo@TLVP(%rip), %rax
Expand Down
4 changes: 4 additions & 0 deletions lld/test/MachO/weak-import.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

# RUN: %lld -weak-lSystem %t/test.o -weak_framework CoreFoundation -weak_library %t/libfoo.dylib -o %t/test
# RUN: llvm-objdump --macho --all-headers %t/test | FileCheck %s -DDIR=%t
# RUN: %lld -weak-lSystem %t/test.o \
# RUN: -framework CoreFoundation -weak_framework CoreFoundation -framework CoreFoundation \
# RUN: %t/libfoo.dylib -weak_library %t/libfoo.dylib %t/libfoo.dylib -o %t/test
# RUN: llvm-objdump --macho --all-headers %t/test | FileCheck %s -DDIR=%t

# CHECK: cmd LC_LOAD_WEAK_DYLIB
# CHECK-NEXT: cmdsize
Expand Down