|
| 1 | +# REQUIRES: x86, shell |
| 2 | +# RUN: mkdir -p %t |
| 3 | +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s \ |
| 4 | +# RUN: -o %t/libhello.o |
| 5 | +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libgoodbye.s \ |
| 6 | +# RUN: -o %t/libgoodbye.o |
| 7 | +# RUN: lld -flavor darwinnew -dylib -install_name \ |
| 8 | +# RUN: @executable_path/libhello.dylib %t/libhello.o -o %t/libhello.dylib |
| 9 | +# RUN: lld -flavor darwinnew -dylib -install_name \ |
| 10 | +# RUN: @executable_path/libgoodbye.dylib %t/libgoodbye.o -o %t/libgoodbye.dylib |
| 11 | + |
| 12 | +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/dylink-lazy.o |
| 13 | +# RUN: lld -flavor darwinnew -o %t/dylink-lazy -L%t -lhello -lgoodbye %t/dylink-lazy.o |
| 14 | + |
| 15 | +## When looking at the __stubs section alone, we are unable to easily tell which |
| 16 | +## symbol each entry points to. So we call objdump twice in order to get the |
| 17 | +## disassembly of __text and the bind tables first, which allow us to check for |
| 18 | +## matching entries in __stubs. |
| 19 | +# RUN: (llvm-objdump -d --no-show-raw-insn --syms --bind --lazy-bind %t/dylink-lazy; \ |
| 20 | +# RUN: llvm-objdump -D --no-show-raw-insn %t/dylink-lazy) | FileCheck %s |
| 21 | + |
| 22 | +# CHECK-LABEL: SYMBOL TABLE: |
| 23 | +# CHECK: {{0*}}[[#%x, IMGLOADER:]] {{.*}} __DATA,__data __dyld_private |
| 24 | + |
| 25 | +# CHECK-LABEL: Disassembly of section __TEXT,__text: |
| 26 | +# CHECK: callq 0x[[#%x, HELLO_STUB:]] |
| 27 | +# CHECK-NEXT: callq 0x[[#%x, GOODBYE_STUB:]] |
| 28 | + |
| 29 | +# CHECK-LABEL: Bind table: |
| 30 | +# CHECK: __DATA_CONST __got 0x[[#%x, BINDER:]] pointer 0 libSystem dyld_stub_binder |
| 31 | + |
| 32 | +# CHECK-LABEL: Lazy bind table: |
| 33 | +# CHECK-DAG: __DATA __la_symbol_ptr 0x{{0*}}[[#%x, HELLO_LAZY_PTR:]] libhello _print_hello |
| 34 | +# CHECK-DAG: __DATA __la_symbol_ptr 0x{{0*}}[[#%x, GOODBYE_LAZY_PTR:]] libgoodbye _print_goodbye |
| 35 | + |
| 36 | +# CHECK-LABEL: Disassembly of section __TEXT,__stubs: |
| 37 | +# CHECK-DAG: [[#%x, HELLO_STUB]]: jmpq *[[#%u, HELLO_LAZY_PTR - HELLO_STUB - 6]](%rip) |
| 38 | +# CHECK-DAG: [[#%x, GOODBYE_STUB]]: jmpq *[[#%u, GOODBYE_LAZY_PTR - GOODBYE_STUB - 6]](%rip) |
| 39 | + |
| 40 | +# CHECK-LABEL: Disassembly of section __TEXT,__stub_helper: |
| 41 | +# CHECK: {{0*}}[[#%x, STUB_HELPER_ENTRY:]] <__stub_helper>: |
| 42 | +# CHECK-NEXT: leaq [[#%u, IMGLOADER - STUB_HELPER_ENTRY - 7]](%rip), %r11 |
| 43 | +# CHECK-NEXT: pushq %r11 |
| 44 | +# CHECK-NEXT: jmpq *[[#%u, BINDER_OFF:]](%rip) |
| 45 | +# CHECK-NEXT: [[#%x, BINDER - BINDER_OFF]]: nop |
| 46 | +# CHECK-NEXT: pushq $0 |
| 47 | +# CHECK-NEXT: jmp 0x[[#STUB_HELPER_ENTRY]] |
| 48 | +# CHECK-NEXT: pushq $21 |
| 49 | +# CHECK-NEXT: jmp 0x[[#STUB_HELPER_ENTRY]] |
| 50 | + |
| 51 | +.text |
| 52 | +.globl _main |
| 53 | + |
| 54 | +_main: |
| 55 | + sub $8, %rsp # 16-byte-align the stack; dyld checks for this |
| 56 | + callq _print_hello |
| 57 | + callq _print_goodbye |
| 58 | + add $8, %rsp |
| 59 | + ret |
0 commit comments