90 lines · plain
1# REQUIRES: x862# RUN: rm -rf %t; split-file %s %t3 4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/foo.o %t/foo.s5# RUN: %lld -dylib -o %t/foo.dylib %t/foo.o6 7# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main.o %t/main.s8 9# _foo starts out as a (non-weak) dynamically looked up symbol and is merged10# against the Undefined from foo.o. _bar isn't referenced in any object file,11# but starts out as Undefined because of the -u flag. _baz isn't referenced12# at all.13# RUN: %lld -lSystem %t/main.o -U _foo -U _bar -u _bar -U _baz -o %t/out14# RUN: llvm-objdump --macho --lazy-bind %t/out | FileCheck --check-prefix=DYNAMIC %s15# RUN: llvm-nm -m %t/out | FileCheck --check-prefix=DYNAMICSYM %s16 17# Same thing should happen if _foo starts out as an Undefined.18# `-U _foo` being passed twice shouldn't have an effect either.19# RUN: %lld -lSystem %t/main.o -u _foo -U _foo -U _foo -u _bar -U _bar -U _baz -o %t/out20# RUN: llvm-objdump --macho --lazy-bind %t/out | FileCheck --check-prefix=DYNAMIC %s21# RUN: llvm-nm -m %t/out | FileCheck --check-prefix=DYNAMICSYM %s22 23# Unreferenced dynamic lookup symbols don't make it into the bind tables, but24# they do make it into the symbol table in ld64 if they're an undefined from -u25# for some reason. lld happens to have the same behavior when no explicit code26# handles this case, so match ld64's behavior.27 28# DYNAMIC-NOT: _bar29# DYNAMIC-NOT: _baz30# DYNAMIC: flat-namespace _foo31 32# DYNAMICSYM: (undefined) external _bar (dynamically looked up)33# DYNAMICSYM-NOT: (undefined) external _bar (dynamically looked up)34# DYNAMICSYM-NEXT: (undefined) external _foo (dynamically looked up)35 36# Test with a Defined. Here, foo.o provides _foo and the symbol doesn't need37# to be imported.38# RUN: %lld -lSystem %t/main.o %t/foo.o -U _foo -o %t/out39# RUN: llvm-objdump --macho --lazy-bind %t/out | FileCheck --check-prefix=NOTDYNAMIC %s40 41# NOTDYNAMIC-NOT: _foo42 43# Here, foo.dylib provides _foo and the symbol doesn't need to be imported44# dynamically.45# RUN: %lld -lSystem %t/main.o %t/foo.dylib -U _foo -o %t/out46# RUN: llvm-objdump --macho --lazy-bind %t/out | FileCheck --check-prefix=TWOLEVEL %s47# RUN: llvm-nm -m %t/out | FileCheck --check-prefix=TWOLEVELSYM %s48 49# TWOLEVEL: foo _foo50# TWOLEVELSYM: (undefined) external _foo (from foo)51 52# Test resolving dynamic lookup symbol with weak defined.53# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/weak-foo.o %t/weak-foo.s54# RUN: %lld -dylib -o %t/weak-foo.dylib %t/weak-foo.o -U _foo55# RUN: llvm-objdump --macho --bind --lazy-bind --weak-bind %t/weak-foo.dylib | FileCheck --check-prefix=WEAKDEF %s56# RUN: llvm-nm -m %t/weak-foo.dylib | FileCheck --check-prefix=WEAKDEFSYM %s57# WEAKDEF-NOT: _foo58# WEAKDEFSYM: weak external _foo59 60# Same if foo.dylib provides _foo weakly, except that the symbol is weak then.61# RUN: %lld -lSystem %t/main.o %t/weak-foo.dylib -U _foo -o %t/out62# RUN: llvm-objdump --macho --bind --lazy-bind --weak-bind %t/out | FileCheck --check-prefix=TWOLEVELWEAK %s63# RUN: llvm-nm -m %t/out | FileCheck --check-prefix=TWOLEVELWEAKSYM %s64 65# TWOLEVELWEAK-LABEL: Bind table:66# TWOLEVELWEAK: __DATA __la_symbol_ptr 0x[[#%x,ADDR:]] pointer 0 weak-foo _foo67# TWOLEVELWEAK-LABEL: Lazy bind table:68# TWOLEVELWEAK-NOT: weak-foo _foo69# TWOLEVELWEAK-LABEL: Weak bind table:70# TWOLEVELWEAK: __DATA __la_symbol_ptr 0x[[#ADDR]] pointer 0 _foo71 72# TWOLEVELWEAKSYM: (undefined) weak external _foo (from weak-foo)73 74#--- foo.s75.globl _foo76_foo:77 ret78 79#--- weak-foo.s80.globl _foo81.weak_definition _foo82_foo:83 ret84 85#--- main.s86.globl _main87_main:88 callq _foo89 ret90