[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / sysroot.s
blob360944039345b2f26246c242b0cf94afd345e976
1 // REQUIRES: x86
2 // RUN: mkdir -p %t/lib
3 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t/m.o
4 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
5 // RUN: %p/Inputs/libsearch-st.s -o %t/st.o
6 // RUN: rm -f %t/lib/libls.a
7 // RUN: llvm-ar rcs %t/lib/libls.a %t/st.o
9 // Should not link because of undefined symbol _bar
10 // RUN: not ld.lld -o /dev/null %t/m.o 2>&1 \
11 // RUN: | FileCheck --check-prefix=UNDEFINED %s
12 // UNDEFINED: error: undefined symbol: _bar
13 // UNDEFINED: >>> referenced by {{.*}}:(.text+0x1)
15 // We need to be sure that there is no suitable library in the /lib directory
16 // RUN: not ld.lld -o /dev/null %t/m.o -L/lib -l:libls.a 2>&1 \
17 // RUN: | FileCheck --check-prefix=NOLIB %s
18 // NOLIB: unable to find library -l:libls.a
20 // Should just remove the '=' symbol if --sysroot is not specified.
21 // Case 1: relative path
22 // RUN: cd %t && ld.lld -o %t/r %t/m.o -L=lib -l:libls.a
23 // Case 2: absolute path
24 // RUN: cd %p && ld.lld -o %t/r %t/m.o -L=%t/lib -l:libls.a
26 // RUN: cd %p
28 // Should substitute SysRoot if specified
29 // RUN: ld.lld -o %t/r %t/m.o --sysroot=%t -L=lib -l:libls.a
30 // RUN: ld.lld -o %t/r %t/m.o --sysroot=%t -L=/lib -l:libls.a
31 // Check alias.
32 // RUN: ld.lld -o %t/r %t/m.o --sysroot %t -L=lib -l:libls.a
34 // Should not substitute SysRoot if the directory name does not start with '='
35 // RUN: not ld.lld -o /dev/null %r/m.o --sysroot=%t -Llib -l:libls.a
36 // RUN: not ld.lld -o /dev/null %r/m.o --sysroot=%t -L/lib -l:libls.a
38 .globl _start,_bar
39 _start:
40 call _bar