2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
4 # RUN: %p/Inputs/abs.s -o %tabs.o
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
6 # RUN: %p/Inputs/shared.s -o %tshared.o
8 # RUN: llvm-ar rcs %tar.a %tabs.o %tshared.o
10 # Symbols from the archive are not in if not needed
11 # RUN: ld.lld -o %t1 %t.o %tar.a
12 # RUN: llvm-readobj --symbols %t1 | FileCheck --check-prefix=NO-UNDEFINED %s
13 # NO-UNDEFINED: Symbols [
14 # NO-UNDEFINED-NOT: Name: abs
15 # NO-UNDEFINED-NOT: Name: big
16 # NO-UNDEFINED-NOT: Name: bar
17 # NO-UNDEFINED-NOT: Name: zed
20 # Symbols from the archive are in if needed, but only from the
21 # containing object file
22 # RUN: ld.lld -o %t2 %t.o %tar.a -u bar
23 # RUN: llvm-readobj --symbols %t2 | FileCheck --check-prefix=ONE-UNDEFINED %s
24 # ONE-UNDEFINED: Symbols [
25 # ONE-UNDEFINED-NOT: Name: abs
26 # ONE-UNDEFINED-NOT: Name: big
27 # ONE-UNDEFINED: Name: bar
28 # ONE-UNDEFINED: Name: zed
31 # Use the option couple of times, both short and long forms
32 # RUN: ld.lld -o %t3 %t.o %tar.a -u bar --undefined=abs
33 # RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=TWO-UNDEFINED %s
34 # RUN: ld.lld -o %t3 %t.o %tar.a -u bar --undefined abs
35 # RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=TWO-UNDEFINED %s
36 # TWO-UNDEFINED: Symbols [
37 # TWO-UNDEFINED: Name: abs
38 # TWO-UNDEFINED: Name: big
39 # TWO-UNDEFINED: Name: bar
40 # TWO-UNDEFINED: Name: zed
42 # Now the same logic but linker script is used to set undefines
43 # RUN: echo "EXTERN( bar \"abs\" )" > %t.script
44 # RUN: ld.lld -o %t3 %t.o %tar.a %t.script
45 # RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=TWO-UNDEFINED %s
47 # Added undefined symbol may be left undefined without error, but
48 # shouldn't show up in the dynamic table.
49 # RUN: ld.lld -shared -o %t4 %t.o %tar.a -u unknown
50 # RUN: llvm-readobj --dyn-symbols %t4 | \
51 # RUN: FileCheck --check-prefix=UNK-UNDEFINED-SO %s
52 # UNK-UNDEFINED-SO: DynamicSymbols [
53 # UNK-UNDEFINED-SO-NOT: Name: unknown
56 # Added undefined symbols should appear in the dynamic table if necessary.
57 # RUN: ld.lld -shared -soname=t -o %t.so %t.o -u export
58 # RUN: llvm-readobj --dyn-symbols %t.so | \
59 # RUN: FileCheck --check-prefix=EXPORT-SO %s
60 # EXPORT-SO: DynamicSymbols [
61 # EXPORT-SO: Name: export
64 ## Test that we handle -u before input files: if we handle -u after
65 ## %t.so, foo would be undefined in the output.
66 # RUN: rm -f %t.a && llvm-ar rc %t.a %t.o
67 # RUN: ld.lld -u export %t.a %t.so -o %t5
68 # RUN: llvm-readobj --dyn-symbols %t5 | FileCheck --check-prefix=EXPORT-SO %s