xref: /llvm-project/lld/test/ELF/sysroot.s (revision 81cebfd0080e3873d0cef5ee5215b8c97332ff96)
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
8
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)
14
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
19
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
25
26// RUN: cd %p
27
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
33
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
37
38.globl _start,_bar
39_start:
40  call _bar
41