llvm-project
50 строк · 1.8 Кб
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
9
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
15
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
19
20## Also check that defined symbols take precedence over dylib symbols.
21# DYLIB-FIRST-NOT: libresolution _bar
22# DYLIB-FIRST-NOT: libresolution _baz
23
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
32
33#--- libresolution.s
34.globl _foo, _bar, _baz
35_foo:
36_bar:
37_baz:
38
39#--- resolution.s
40.globl _main, _bar
41# Global defined symbol
42_bar:
43# Local defined symbol
44_baz:
45
46_main:
47movq _foo@GOTPCREL(%rip), %rsi
48movq _bar@GOTPCREL(%rip), %rsi
49movq _baz@GOTPCREL(%rip), %rsi
50ret
51