97 lines · plain
1# REQUIRES: x862# RUN: 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 -install_name @executable_path/libhello.dylib \8# RUN: -compatibility_version 10 -current_version 11 \9# RUN: %t/libhello.o -o %t/libhello.dylib10# RUN: %lld -dylib -install_name \11# RUN: @executable_path/libgoodbye.dylib %t/libgoodbye.o -o %t/libgoodbye.dylib12 13## Make sure we are using the export trie and not the symbol table when linking14## against these dylibs.15# RUN: llvm-strip %t/libhello.dylib16# RUN: llvm-strip %t/libgoodbye.dylib17# RUN: llvm-nm %t/libhello.dylib 2>&1 | FileCheck %s --check-prefix=NOSYM18# RUN: llvm-nm %t/libgoodbye.dylib 2>&1 | FileCheck %s --check-prefix=NOSYM19# NOSYM: no symbols20 21# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/dylink.o22# RUN: %lld -o %t/dylink -L%t -lhello -lgoodbye %t/dylink.o23# RUN: llvm-objdump --no-print-imm-hex --bind -d --no-show-raw-insn %t/dylink | FileCheck %s24 25# CHECK: movq [[#%u, HELLO_OFF:]](%rip), %rsi26# CHECK-NEXT: [[#%x, HELLO_RIP:]]:27 28# CHECK: movq [[#%u, HELLO_ITS_ME_OFF:]](%rip), %rsi29# CHECK-NEXT: [[#%x, HELLO_ITS_ME_RIP:]]:30 31# CHECK: pushq [[#%u, GOODBYE_OFF:]](%rip)32# CHECK-NEXT: [[#%x, GOODBYE_RIP:]]: popq %rsi33 34# CHECK-LABEL: Bind table:35# CHECK-DAG: __DATA_CONST __got 0x{{0*}}[[#%x, HELLO_RIP + HELLO_OFF]] pointer 0 libhello _hello_world36# CHECK-DAG: __DATA_CONST __got 0x{{0*}}[[#%x, HELLO_ITS_ME_RIP + HELLO_ITS_ME_OFF]] pointer 0 libhello _hello_its_me37# CHECK-DAG: __DATA_CONST __got 0x{{0*}}[[#%x, GOODBYE_RIP + GOODBYE_OFF]] pointer 0 libgoodbye _goodbye_world38# CHECK-DAG: __DATA __data 0x[[#%x, DATA_ADDR:]] pointer 0 libhello _hello_world39# CHECK-DAG: __DATA __data 0x{{0*}}[[#%x, DATA_ADDR + 8]] pointer 8 libhello _hello_its_me40# CHECK-DAG: __DATA __data 0x{{0*}}[[#%x, DATA_ADDR + 16]] pointer -15 libgoodbye _goodbye_world41 42# RUN: llvm-nm -m %t/dylink | FileCheck --check-prefix=NM %s43 44# NM-DAG: _goodbye_world (from libgoodbye)45# NM-DAG: _hello_its_me (from libhello)46# NM-DAG: _hello_world (from libhello)47 48# RUN: llvm-objdump --macho --all-headers %t/dylink | FileCheck %s \49# RUN: --check-prefix=LOAD --implicit-check-not LC_LOAD_DYLIB50## Check that we don't create duplicate LC_LOAD_DYLIBs.51# RUN: %lld -o %t/dylink -L%t -lhello -lhello -lgoodbye -lgoodbye %t/dylink.o52# RUN: llvm-objdump --macho --all-headers %t/dylink | FileCheck %s \53# RUN: --check-prefix=LOAD --implicit-check-not LC_LOAD_DYLIB54 55# LOAD: cmd LC_LOAD_DYLIB56# LOAD-NEXT: cmdsize57# LOAD-NEXT: name /usr/lib/libSystem.dylib58# LOAD: cmd LC_LOAD_DYLIB59# LOAD-NEXT: cmdsize60# LOAD-NEXT: name @executable_path/libhello.dylib61# LOAD-NEXT: time stamp62# LOAD-NEXT: current version 11.0.063# LOAD-NEXT: compatibility version 10.0.064# LOAD: cmd LC_LOAD_DYLIB65# LOAD-NEXT: cmdsize66# LOAD-NEXT: name @executable_path/libgoodbye.dylib67 68.section __TEXT,__text69.globl _main70 71_main:72 movl $0x2000004, %eax # write() syscall73 mov $1, %rdi # stdout74 movq _hello_world@GOTPCREL(%rip), %rsi75 mov $13, %rdx # length of str76 syscall77 78 movl $0x2000004, %eax # write() syscall79 mov $1, %rdi # stdout80 movq _hello_its_me@GOTPCREL(%rip), %rsi81 mov $15, %rdx # length of str82 syscall83 84 movl $0x2000004, %eax # write() syscall85 mov $1, %rdi # stdout86 pushq _goodbye_world@GOTPCREL(%rip)87 popq %rsi88 mov $15, %rdx # length of str89 syscall90 mov $0, %rax91 ret92 93.data94.quad _hello_world95.quad _hello_its_me + 0x896.quad _goodbye_world - 0xf97