2 # RUN: rm -rf %t && split-file %s %t && cd %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o && ld.lld a.o -shared -o a.so
4 # RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o && ld.lld b.o -shared -o b.so
5 # RUN: llvm-ar rc a.a a.o
6 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux ref.s -o ref.o
7 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux ref2.s -o ref2.o
8 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux weakref2.s -o weakref2.o
9 # RUN: ld.lld a.a b.so ref.o -shared -o 1.so
10 # RUN: llvm-readelf --dyn-syms 1.so | FileCheck %s
11 # RUN: ld.lld a.so a.a ref.o -shared -o 1.so
12 # RUN: llvm-readelf --dyn-syms 1.so | FileCheck %s
14 ## The definitions from a.so are used and we don't extract a member from the
17 # CHECK: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND x1
18 # CHECK-NEXT: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND x2
20 ## The extracted x1 is defined as STB_GLOBAL.
21 # RUN: ld.lld ref.o a.a b.so -o 2.so -shared
22 # RUN: llvm-readelf --dyn-symbols 2.so | FileCheck %s --check-prefix=CHECK2
23 # RUN: ld.lld a.a ref.o b.so -o 2.so -shared
24 # RUN: llvm-readelf --dyn-symbols 2.so | FileCheck %s --check-prefix=CHECK2
26 # CHECK2: {{.*}} 0 NOTYPE GLOBAL DEFAULT [[#]] x1
27 # CHECK2-NEXT: {{.*}} 0 NOTYPE WEAK DEFAULT [[#]] x2
29 ## The extracted x2 is defined as STB_WEAK. x1 is not referenced by any relocatable object file.
30 # RUN: ld.lld a.a ref2.o b.so -o 2.so -shared
31 # RUN: llvm-readelf --dyn-syms 2.so | FileCheck %s --check-prefix=CHECK2
32 # RUN: ld.lld a.a a.so ref2.o -o 3.so -shared
33 # RUN: llvm-readelf --dyn-syms 3.so | FileCheck %s --check-prefix=CHECK3
34 # RUN: ld.lld a.so a.a ref2.o -o 3.so -shared
35 # RUN: llvm-readelf --dyn-syms 3.so | FileCheck %s --check-prefix=CHECK3
37 # CHECK3: 1: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND x2
40 # RUN: ld.lld a.a weakref2.o a.so -o 4.so -shared
41 # RUN: llvm-readelf --dyn-syms 4.so | FileCheck %s --check-prefix=CHECK4
43 # CHECK4: 1: 0000000000000000 0 NOTYPE WEAK DEFAULT UND x2
46 # RUN: ld.lld a.a --as-needed a.so -o noneeded.so -shared
47 # RUN: llvm-readelf -d noneeded.so | FileCheck %s --check-prefix=NONEEDED
49 # NONEEDED-NOT: NEEDED