brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · 66b87e9 Raw
109 lines · plain
1// REQUIRES: x862// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o3// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \4// RUN:   %p/Inputs/libsearch-dyn.s -o %tdyn.o5// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \6// RUN:   %p/Inputs/libsearch-st.s -o %tst.o7// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \8// RUN:   %p/Inputs/use-bar.s -o %tbar.o9// RUN: mkdir -p %t.dir10// RUN: ld.lld -shared %tdyn.o -o %t.dir/libls.so11// RUN: cp -f %t.dir/libls.so %t.dir/libls2.so12// RUN: rm -f %t.dir/libls.a13// RUN: llvm-ar rcs %t.dir/libls.a %tst.o14 15// Should fail if no library specified16// RUN: not ld.lld -l 2>&1 \17// RUN:   | FileCheck --check-prefix=NOLIBRARY %s18// NOLIBRARY: -l: missing argument19 20// Should link normally, because _bar is not used21// RUN: ld.lld -o %t3 %t.o22// Should not link because of undefined symbol _bar23// RUN: not ld.lld -o /dev/null %t.o %tbar.o 2>&1 \24// RUN:   | FileCheck --check-prefix=UNDEFINED %s25// UNDEFINED: error: undefined symbol: _bar26// UNDEFINED: >>> referenced by {{.*}}:(.bar+0x0)27 28// Should fail if cannot find specified library (without -L switch)29// RUN: not ld.lld -o /dev/null %t.o -lls 2>&1 \30// RUN:   | FileCheck --check-prefix=NOLIB %s31// NOLIB: unable to find library -lls32 33// Should use explicitly specified static library34// Also ensure that we accept -L <arg>35// RUN: ld.lld -o %t3 %t.o -L %t.dir -l:libls.a36// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s37// STATIC: Symbols [38// STATIC: Name: _static39// STATIC: ]40 41// Should use explicitly specified dynamic library42// RUN: ld.lld -o %t3 %t.o -L%t.dir -l:libls.so43// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s44// DYNAMIC: Symbols [45// DYNAMIC-NOT: Name: _static46// DYNAMIC: ]47 48// Should prefer dynamic to static49// RUN: ld.lld -o %t3 %t.o -L%t.dir -lls50// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s51 52// Check for library search order53// RUN: mkdir -p %t.dir254// RUN: cp %t.dir/libls.a %t.dir255// RUN: ld.lld -o %t3 %t.o -L%t.dir2 -L%t.dir -lls56// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s57 58// -L can be placed after -l59// RUN: ld.lld -o %t3 %t.o -lls -L%t.dir60 61// Check long forms as well62// RUN: ld.lld -o %t3 %t.o --library-path=%t.dir --library=ls63// RUN: ld.lld -o %t3 %t.o --library-path %t.dir --library ls64 65// Should not search for dynamic libraries if -Bstatic is specified66// RUN: ld.lld -o %t3 %t.o -L%t.dir -Bstatic -lls67// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s68// RUN: not ld.lld -o /dev/null %t.o -L%t.dir -Bstatic -lls2 2>&1 \69// RUN:   | FileCheck --check-prefix=NOLIB2 %s70// NOLIB2: unable to find library -lls271 72// -Bdynamic should restore default behaviour73// RUN: ld.lld -o %t3 %t.o -L%t.dir -Bstatic -Bdynamic -lls74// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s75 76// -Bstatic and -Bdynamic should affect only libraries which follow them77// RUN: ld.lld -o %t3 %t.o -L%t.dir -lls -Bstatic -Bdynamic78// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s79// RUN: ld.lld -o %t3 %t.o -L%t.dir -Bstatic -lls -Bdynamic80// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s81 82// Check aliases as well83// RUN: ld.lld -o %t3 %t.o -L%t.dir -dn -lls84// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s85// RUN: ld.lld -o %t3 %t.o -L%t.dir -non_shared -lls86// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s87// RUN: ld.lld -o %t3 %t.o -L%t.dir -static -lls88// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s89// RUN: ld.lld -o %t3 %t.o -L%t.dir -Bstatic -dy -lls90// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s91// RUN: ld.lld -o %t3 %t.o -L%t.dir -Bstatic -call_shared -lls92// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s93 94/// -r implies -Bstatic and has precedence over -Bdynamic.95// RUN: ld.lld -r -Bdynamic %t.o -L%t.dir -lls -o %t3.ro96// RUN: llvm-readelf -s -h %t3.ro | FileCheck --check-prefix=RELOCATABLE %s97// RELOCATABLE: Type: REL98// RELOCATABLE: [[#]] _static99 100// -nostdlib101// RUN: echo 'SEARCH_DIR("'%t.dir'")' > %t.script102// RUN: ld.lld -o %t3 %t.o -script %t.script -lls103// RUN: not ld.lld -o /dev/null %t.o -script %t.script -lls -nostdlib \104// RUN:   2>&1 | FileCheck --check-prefix=NOSTDLIB %s105// NOSTDLIB: unable to find library -lls106 107.globl _start,_bar108_start:109