108 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/bar.o %t/bar.s8# RUN: %lld -lSystem -dylib -o %t/bar.dylib %t/bar.o %t/foo.dylib9 10# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/baz.o %t/baz.s11# RUN: %lld -lSystem -dylib -o %t/baz.dylib %t/baz.o %t/bar.dylib12 13# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main.o %t/main.s14 15## With flat_namespace, the linker automatically looks in foo.dylib and16## bar.dylib too, but it doesn't add a LC_LOAD_DYLIB for it.17# RUN: %lld -flat_namespace -lSystem %t/main.o %t/baz.dylib -o %t/out -t \18# RUN: --reproduce %t/repro.tar | FileCheck --check-prefix=T %s19## FIXME: The `bar.dylib` line should use `T-NEXT`, but on Windows we load20## libSystem.tbd with different slash styles and end up loading it twice21## for that reason.22# T: main.o23# T-NEXT: baz.dylib24# T: bar.dylib25# T-NEXT: foo.dylib26# RUN: llvm-objdump --macho --all-headers %t/out \27# RUN: | FileCheck --check-prefix=HEADERBITS %s28# RUN: llvm-objdump --macho --bind --lazy-bind --weak-bind %t/out \29# RUN: | FileCheck --check-prefix=FLAT %s30# RUN: llvm-nm -m %t/out | FileCheck --check-prefix=FLATSYM %s31# RUN: llvm-readobj --syms %t/out | FileCheck --check-prefix=FLATSYM-READOBJ %s32# RUN: cd %t33# RUN: tar -tf repro.tar | FileCheck -DPATH='%:t.dir' --check-prefix=REPRO %s34# RUN: tar -xf repro.tar repro/response.txt35# RUN: FileCheck --implicit-check-not=.dylib --check-prefix=RESPONSE %s \36# RUN: < %t/repro/response.txt37 38# HEADERBITS-NOT: NOUNDEFS39# HEADERBITS-NOT: TWOLEVEL40# HEADERBITS: DYLDLINK41# HEADERBITS-NOT: foo.dylib42# HEADERBITS-NOT: bar.dylib43 44# FLAT: Bind table:45# FLAT: __DATA_CONST __got 0x{{[0-9a-f]*}} pointer 0 flat-namespace dyld_stub_binder46# FLAT: Lazy bind table:47# FLAT-DAG: __DATA __la_symbol_ptr 0x{{[0-9a-f]*}} flat-namespace _bar48# FLAT-DAG: __DATA __la_symbol_ptr 0x{{[0-9a-f]*}} flat-namespace _baz49# FLAT-DAG: __DATA __la_symbol_ptr 0x{{[0-9a-f]*}} flat-namespace _foo50 51## No "(dynamically looked up)" because llvm-nm -m doesn't print that52## for files without MH_TWOLEVEL for some reason.53# FLATSYM: (undefined) external _bar54# FLATSYM: (undefined) external _baz55# FLATSYM: (undefined) external _foo56 57## ...but `llvm-readobj --syms` does, so verify we put the right thing there.58# FLATSYM-READOBJ: Flags [ (0xFE00)59 60## All 3 .dylibs should be in a --reproduce archive.61# REPRO: baz.dylib62# REPRO: bar.dylib63# REPRO: foo.dylib64 65## ...but only baz.dylib should be in the response file:66# RESPONSE: baz.dylib67 68# Undefined symbols should still cause errors by default.69# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos \70# RUN: -o %t/main-with-undef.o %t/main-with-undef.s71# RUN: not %lld -flat_namespace -lSystem %t/main-with-undef.o %t/bar.dylib \72# RUN: -o %t/out 2>&1 | FileCheck --check-prefix=UNDEF %s73# UNDEF: error: undefined symbol: _quux74 75#--- foo.s76.globl _foo77_foo:78 ret79 80#--- bar.s81.globl _bar82_bar:83 callq _foo84 ret85 86#--- baz.s87.globl _baz88_baz:89 callq _bar90 ret91 92#--- main.s93.globl _main94_main:95 callq _foo96 callq _bar97 callq _baz98 ret99 100#--- main-with-undef.s101.globl _main102_main:103 callq _foo104 callq _bar105 callq _baz106 callq _quux107 ret108