2015-10-05 17:43:57 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
|
|
|
|
# RUN: %p/Inputs/abs.s -o %tabs.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
|
|
|
|
# RUN: %p/Inputs/shared.s -o %tshared.o
|
|
|
|
# RUN: rm -f %tar.a
|
|
|
|
# RUN: llvm-ar rcs %tar.a %tabs.o %tshared.o
|
|
|
|
# REQUIRES: x86
|
|
|
|
|
|
|
|
# Symbols from the archive are not in if not needed
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: ld.lld -o %t1 %t.o %tar.a
|
2015-10-05 17:43:57 +08:00
|
|
|
# RUN: llvm-readobj --symbols %t1 | FileCheck --check-prefix=NO-UNDEFINED %s
|
|
|
|
# NO-UNDEFINED: Symbols [
|
|
|
|
# NO-UNDEFINED-NOT: Name: abs
|
|
|
|
# NO-UNDEFINED-NOT: Name: big
|
|
|
|
# NO-UNDEFINED-NOT: Name: bar
|
|
|
|
# NO-UNDEFINED-NOT: Name: zed
|
|
|
|
# NO-UNDEFINED: ]
|
|
|
|
|
|
|
|
# Symbols from the archive are in if needed, but only from the
|
|
|
|
# containing object file
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: ld.lld -o %t2 %t.o %tar.a -u bar
|
2015-10-05 17:43:57 +08:00
|
|
|
# RUN: llvm-readobj --symbols %t2 | FileCheck --check-prefix=ONE-UNDEFINED %s
|
|
|
|
# ONE-UNDEFINED: Symbols [
|
|
|
|
# ONE-UNDEFINED-NOT: Name: abs
|
|
|
|
# ONE-UNDEFINED-NOT: Name: big
|
|
|
|
# ONE-UNDEFINED: Name: bar
|
|
|
|
# ONE-UNDEFINED: Name: zed
|
|
|
|
# ONE-UNDEFINED: ]
|
|
|
|
|
|
|
|
# Use the option couple of times, both short and long forms
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: ld.lld -o %t3 %t.o %tar.a -u bar --undefined=abs
|
2015-10-05 17:43:57 +08:00
|
|
|
# RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=TWO-UNDEFINED %s
|
2016-09-09 04:35:29 +08:00
|
|
|
# RUN: ld.lld -o %t3 %t.o %tar.a -u bar --undefined abs
|
|
|
|
# RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=TWO-UNDEFINED %s
|
2015-10-05 17:43:57 +08:00
|
|
|
# TWO-UNDEFINED: Symbols [
|
|
|
|
# TWO-UNDEFINED: Name: abs
|
|
|
|
# TWO-UNDEFINED: Name: big
|
|
|
|
# TWO-UNDEFINED: Name: bar
|
|
|
|
# TWO-UNDEFINED: Name: zed
|
|
|
|
# TWO-UNDEFINED: ]
|
2015-10-20 01:35:12 +08:00
|
|
|
# Now the same logic but linker script is used to set undefines
|
|
|
|
# RUN: echo "EXTERN( bar abs )" > %t.script
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: ld.lld -o %t3 %t.o %tar.a %t.script
|
2015-10-20 01:35:12 +08:00
|
|
|
# RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=TWO-UNDEFINED %s
|
2015-10-05 17:43:57 +08:00
|
|
|
|
|
|
|
# Added undefined symbol may be left undefined without error, but
|
|
|
|
# shouldn't show up in the dynamic table.
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: ld.lld -shared -o %t4 %t.o %tar.a -u unknown
|
2015-10-05 17:43:57 +08:00
|
|
|
# RUN: llvm-readobj --dyn-symbols %t4 | \
|
|
|
|
# RUN: FileCheck --check-prefix=UNK-UNDEFINED-SO %s
|
|
|
|
# UNK-UNDEFINED-SO: DynamicSymbols [
|
|
|
|
# UNK-UNDEFINED-SO-NOT: Name: unknown
|
|
|
|
# UNK-UNDEFINED-SO: ]
|
|
|
|
|
2016-04-27 08:05:03 +08:00
|
|
|
# Added undefined symbols should appear in the dynamic table if necessary.
|
|
|
|
# RUN: ld.lld -shared -o %t5 %t.o -u export
|
|
|
|
# RUN: llvm-readobj --dyn-symbols %t5 | \
|
|
|
|
# RUN: FileCheck --check-prefix=EXPORT-SO %s
|
|
|
|
# EXPORT-SO: DynamicSymbols [
|
|
|
|
# EXPORT-SO: Name: export
|
|
|
|
# EXPORT-SO: ]
|
|
|
|
|
2016-04-27 10:58:27 +08:00
|
|
|
.globl _start
|
2015-10-05 17:43:57 +08:00
|
|
|
_start:
|
2016-04-27 08:05:03 +08:00
|
|
|
|
|
|
|
.globl export
|
|
|
|
export:
|