Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / symbol-resolution.s
blobda6ed086548fd7552c11dfa05d6af0dac6465ffa
1 # REQUIRES: x86
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
11 ## command line.
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
33 #--- libresolution.s
34 .globl _foo, _bar, _baz
35 _foo:
36 _bar:
37 _baz:
39 #--- resolution.s
40 .globl _main, _bar
41 # Global defined symbol
42 _bar:
43 # Local defined symbol
44 _baz:
46 _main:
47 movq _foo@GOTPCREL(%rip), %rsi
48 movq _bar@GOTPCREL(%rip), %rsi
49 movq _baz@GOTPCREL(%rip), %rsi
50 ret