2 # RUN: rm -rf %t; split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/foo.o %t/foo.s
5 # RUN: %lld -dylib -o %t/foo.dylib %t/foo.o
7 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/bar.o %t/bar.s
8 # RUN: %lld -lSystem -dylib -o %t/bar.dylib %t/bar.o %t/foo.dylib
10 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/baz.o %t/baz.s
11 # RUN: %lld -lSystem -dylib -o %t/baz.dylib %t/baz.o %t/bar.dylib
13 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main.o %t/main.s
15 ## With flat_namespace, the linker automatically looks in foo.dylib and
16 ## 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 %s
19 ## FIXME: The `bar.dylib` line should use `T-NEXT`, but on Windows we load
20 ## libSystem.tbd with different slash styles and end up loading it twice
26 # RUN: llvm-objdump --macho --all-headers %t/out \
27 # RUN: | FileCheck --check-prefix=HEADERBITS %s
28 # RUN: llvm-objdump --macho --bind --lazy-bind --weak-bind %t/out \
29 # RUN: | FileCheck --check-prefix=FLAT %s
30 # RUN: llvm-nm -m %t/out | FileCheck --check-prefix=FLATSYM %s
31 # RUN: llvm-readobj --syms %t/out | FileCheck --check-prefix=FLATSYM-READOBJ %s
33 # RUN: tar -tf repro.tar | FileCheck -DPATH='%:t.dir' --check-prefix=REPRO %s
34 # RUN: tar -xf repro.tar repro/response.txt
35 # RUN: FileCheck --implicit-check-not=dylib --check-prefix=RESPONSE %s \
36 # RUN: < %t/repro/response.txt
38 # HEADERBITS-NOT: NOUNDEFS
39 # HEADERBITS-NOT: TWOLEVEL
40 # HEADERBITS: DYLDLINK
41 # HEADERBITS-NOT: foo.dylib
42 # HEADERBITS-NOT: bar.dylib
45 # FLAT: __DATA_CONST __got 0x{{[0-9a-f]*}} pointer 0 flat-namespace dyld_stub_binder
46 # FLAT: Lazy bind table:
47 # FLAT-DAG: __DATA __la_symbol_ptr 0x{{[0-9a-f]*}} flat-namespace _bar
48 # FLAT-DAG: __DATA __la_symbol_ptr 0x{{[0-9a-f]*}} flat-namespace _baz
49 # FLAT-DAG: __DATA __la_symbol_ptr 0x{{[0-9a-f]*}} flat-namespace _foo
51 ## No "(dynamically looked up)" because llvm-nm -m doesn't print that
52 ## for files without MH_TWOLEVEL for some reason.
53 # FLATSYM: (undefined) external _bar
54 # FLATSYM: (undefined) external _baz
55 # FLATSYM: (undefined) external _foo
57 ## ...but `llvm-readobj --syms` does, so verify we put the right thing there.
58 # FLATSYM-READOBJ: Flags [ (0xFE00)
60 ## All 3 .dylibs should be in a --reproduce archive.
65 ## ...but only baz.dylib should be in the response file:
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.s
71 # 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 %s
73 # UNDEF: error: undefined symbol: _quux
100 #--- main-with-undef.s