2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libresolution.s -o %t/libresolution.o
4 # RUN: %lld -dylib -install_name \
5 # RUN: @executable_path/libresolution.dylib %t/libresolution.o -o %t/libresolution.dylib
6 # RUN: %lld -dylib -install_name \
7 # RUN: @executable_path/libresolution2.dylib %t/libresolution.o -o %t/libresolution2.dylib
8 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/resolution.s -o %t/resolution.o
10 ## Check that we select the symbol defined in the first dylib passed on the
12 # RUN: %lld -o %t/dylib-first -L%t -lresolution -lresolution2 %t/resolution.o
13 # RUN: llvm-objdump --macho --bind %t/dylib-first | FileCheck %s --check-prefix=DYLIB-FIRST
14 # DYLIB-FIRST: libresolution _foo
16 # RUN: %lld -o %t/dylib2-first -L%t -lresolution2 -lresolution %t/resolution.o
17 # RUN: llvm-objdump --macho --bind %t/dylib2-first | FileCheck %s --check-prefix=DYLIB2-FIRST
18 # DYLIB2-FIRST: libresolution2 _foo
20 ## Also check that defined symbols take precedence over dylib symbols.
21 # DYLIB-FIRST-NOT: libresolution _bar
22 # DYLIB-FIRST-NOT: libresolution _baz
24 ## Check that we pick the dylib symbol over the undefined symbol in the object
25 ## file, even if the object file appears first on the command line.
26 # RUN: %lld -o %t/obj-first -L%t %t/resolution.o -lresolution
27 # RUN: llvm-objdump --macho --bind %t/obj-first | FileCheck %s --check-prefix=OBJ-FIRST
28 # OBJ-FIRST: libresolution _foo
29 ## But defined symbols should still take precedence.
30 # OBJ-FIRST-NOT: libresolution _bar
31 # OBJ-FIRST-NOT: libresolution _baz
34 .globl _foo, _bar, _baz
41 # Global defined symbol
43 # Local defined symbol
47 movq _foo@GOTPCREL
(%rip
), %rsi
48 movq _bar@GOTPCREL
(%rip
), %rsi
49 movq _baz@GOTPCREL
(%rip
), %rsi