llvm-project/lld/test/old-elf/dynamic-undef.test

39 lines
2.2 KiB
Plaintext

#
# This test creates a executable and tests the options that are used to
# to create an executable and a shared library
#
# This test will fail because there are unresolved symbols from the shared
# library and we are passing --no-allow-shlib-undefined
RUN: not lld -flavor old-gnu -target x86_64-linux %p/Inputs/tls.x86-64 \
RUN: %p/Inputs/shared.so-x86-64 -o %t -e main --no-allow-shlib-undefined 2> %t1
RUN: FileCheck -check-prefix=EXEC %s < %t1
# This test will pass because of --allow-shlib-undefined
RUN: lld -flavor old-gnu -target x86_64-linux %p/Inputs/tls.x86-64 \
RUN: %p/Inputs/shared.so-x86-64 -o %t -e main --allow-shlib-undefined \
RUN: --defsym=__tls_get_addr=0
# This test will pass becase --allow-shlib-undefined is the default.
RUN: lld -flavor old-gnu -target x86_64-linux %p/Inputs/tls.x86-64 \
RUN: %p/Inputs/shared.so-x86-64 -o %t -e main \
RUN: --defsym=__tls_get_addr=0
# Building shared libraries should not fail when there is a undefined symbol.
# Test creation of shared library, this should pass because we are using
# shared option and by default, dynamic library wouldn't create undefined atoms
# from the input shared library
RUN: lld -flavor old-gnu -target x86_64-linux %p/Inputs/tls.x86-64 \
RUN: %p/Inputs/shared.so-x86-64 -o %t.usenoundefines -e main -shared
RUN: llvm-readobj -symbols %t.usenoundefines | FileCheck %s -check-prefix=SHLIB-NOUNDEF
# Test creation of shared library, this should fail because we are using
# shared option setting the options to use the shared library undefines to
# create undefined atoms from the input shared library
RUN: lld -flavor old-gnu -target x86_64-linux %p/Inputs/tls.x86-64 \
RUN: %p/Inputs/shared.so-x86-64 -o %t.useundefines -e main -shared \
RUN: --use-shlib-undefines --no-allow-shlib-undefined 2> %t2
RUN: llvm-readobj -symbols %t.useundefines | FileCheck -check-prefix=SHLIB-UNDEF-SYMBOLS %s
EXEC: Undefined symbol: {{.+[\\/]}}shared.so-x86-64: puts
SHLIB: Undefined symbol: {{.+[\\/]}}shared.so-x86-64: puts
EXEC-NOT: Undefined symbol: {{.+[\\/]}}shared.so-x86-64: weakfoo
SHLIB-NOT: Undefined symbol: {{.+[\\/]}}shared.so-x86-64: weakfoo
SHLIB-NOUNDEF-NOT: Name: puts
SHLIB-UNDEF-SYMBOLS: Name: puts