79 lines · plain
1# REQUIRES: x862# RUN: rm -rf %t; mkdir -p %t3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s \4# RUN: -o %t/libhello.o5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libgoodbye.s \6# RUN: -o %t/libgoodbye.o7# RUN: %lld -dylib \8# RUN: -install_name @executable_path/libhello.dylib %t/libhello.o \9# RUN: -o %t/libhello.dylib10# RUN: %lld -dylib \11# RUN: -install_name @executable_path/libgoodbye.dylib %t/libgoodbye.o \12# RUN: -o %t/libgoodbye.dylib13 14# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/dylink-lazy.o15# RUN: %lld -no_pie -data_const -o %t/dylink-lazy-no-pie \16# RUN: -L%t -lhello -lgoodbye %t/dylink-lazy.o -lSystem17 18## When looking at the __stubs section alone, we are unable to easily tell which19## symbol each entry points to. So we call objdump twice in order to get the20## disassembly of __text and the bind tables first, which allow us to check for21## matching entries in __stubs.22# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --syms --rebase --bind --lazy-bind %t/dylink-lazy-no-pie > %t/objdump-no-pie23# RUN: llvm-objdump --no-print-imm-hex -D --no-show-raw-insn %t/dylink-lazy-no-pie >> %t/objdump-no-pie24# RUN: FileCheck %s --check-prefixes=CHECK,NO-PIE < %t/objdump-no-pie25 26# RUN: %lld -o %t/dylink-lazy -L%t -lhello -lgoodbye %t/dylink-lazy.o -lSystem27# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --syms --rebase --bind --lazy-bind %t/dylink-lazy > %t/objdump28# RUN: llvm-objdump --no-print-imm-hex -D --no-show-raw-insn %t/dylink-lazy >> %t/objdump29# RUN: FileCheck %s --check-prefixes=CHECK,PIE < %t/objdump30 31# CHECK-LABEL: SYMBOL TABLE:32# CHECK: {{0*}}[[#%x, IMGLOADER:]] l {{.*}} __DATA,__data __dyld_private33 34# CHECK-LABEL: Disassembly of section __TEXT,__text:35# CHECK: callq 0x[[#%x, HELLO_STUB:]]36# CHECK-NEXT: callq 0x[[#%x, GOODBYE_STUB:]]37 38## Check that the rebase table is empty.39# NO-PIE-LABEL: Rebase table:40# NO-PIE-NEXT: segment section address type41 42# PIE-LABEL: Rebase table:43# PIE-NEXT: segment section address type44# PIE-NEXT: __DATA __la_symbol_ptr 0x[[#%X, ADDR:]] pointer45# PIE-NEXT: __DATA __la_symbol_ptr 0x[[#ADDR + 8]] pointer46 47# CHECK-EMPTY:48# CHECK-NEXT: Bind table:49# CHECK: __DATA_CONST __got 0x[[#%x, BINDER:]] pointer 0 libSystem dyld_stub_binder50 51# CHECK-LABEL: Lazy bind table:52# CHECK-DAG: __DATA __la_symbol_ptr 0x{{0*}}[[#%x, HELLO_LAZY_PTR:]] libhello _print_hello53# CHECK-DAG: __DATA __la_symbol_ptr 0x{{0*}}[[#%x, GOODBYE_LAZY_PTR:]] libgoodbye _print_goodbye54 55# CHECK-LABEL: Disassembly of section __TEXT,__stubs:56# CHECK-DAG: [[#%x, HELLO_STUB]]: jmpq *[[#%u, HELLO_LAZY_PTR - HELLO_STUB - 6]](%rip)57# CHECK-DAG: [[#%x, GOODBYE_STUB]]: jmpq *[[#%u, GOODBYE_LAZY_PTR - GOODBYE_STUB - 6]](%rip)58 59# CHECK-LABEL: Disassembly of section __TEXT,__stub_helper:60# CHECK: {{0*}}[[#%x, STUB_HELPER_ENTRY:]] <__stub_helper>:61# CHECK-NEXT: leaq [[#%u, IMGLOADER - STUB_HELPER_ENTRY - 7]](%rip), %r1162# CHECK-NEXT: pushq %r1163# CHECK-NEXT: jmpq *[[#%u, BINDER_OFF:]](%rip)64# CHECK-NEXT: [[#%x, BINDER - BINDER_OFF]]: nop65# CHECK-NEXT: pushq $066# CHECK-NEXT: jmp 0x[[#STUB_HELPER_ENTRY]]67# CHECK-NEXT: pushq $2168# CHECK-NEXT: jmp 0x[[#STUB_HELPER_ENTRY]]69 70.text71.globl _main72 73_main:74 sub $8, %rsp # 16-byte-align the stack; dyld checks for this75 callq _print_hello76 callq _print_goodbye77 add $8, %rsp78 ret79