1// REQUIRES: x86 2// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o 3// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/shared.s -o %t2.o 4// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/shared2.s -o %t3.o 5// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/shared3.s -o %t4.o 6// RUN: ld.lld -shared %t2.o -soname shared1 -o %t2.so 7// RUN: ld.lld -shared %t3.o -soname shared2 -o %t3.so 8// RUN: ld.lld -shared %t4.o -soname shared3 -o %t4.so 9 10/// Check if --as-needed actually works. 11 12// RUN: ld.lld %t.o %t2.so %t3.so %t4.so -o %t2 13// RUN: llvm-readobj --dynamic-table %t2 | FileCheck %s 14 15// RUN: ld.lld --as-needed %t.o %t2.so %t3.so %t4.so -o %t2 16// RUN: llvm-readobj --dynamic-table %t2 | FileCheck -check-prefix=CHECK2 %s 17 18// Test with the .o last 19// RUN: ld.lld --as-needed %t2.so %t3.so %t4.so %t.o -o %t2 20// RUN: llvm-readobj --dynamic-table %t2 | FileCheck -check-prefix=CHECK2 %s 21 22// RUN: ld.lld --as-needed %t.o %t2.so --no-as-needed %t3.so %t4.so -o %t2 23// RUN: llvm-readobj --dynamic-table %t2 | FileCheck %s 24 25/// GROUP command is the same as listing the files on the command line. 26 27// RUN: echo "GROUP(\"%t2.so\" \"%t3.so\" \"%t4.so\")" > %t.script 28// RUN: ld.lld %t.o %t.script -o %t2 29// RUN: llvm-readobj --dynamic-table %t2 | FileCheck %s 30 31// RUN: echo "GROUP(AS_NEEDED(\"%t2.so\" \"%t3.so\" \"%t4.so\"))" > %t.script 32// RUN: ld.lld %t.o %t.script -o %t2 33// RUN: llvm-readobj --dynamic-table %t2 | FileCheck -check-prefix=CHECK2 %s 34 35// CHECK: NEEDED Shared library: [shared1] 36// CHECK: NEEDED Shared library: [shared2] 37// CHECK: NEEDED Shared library: [shared3] 38 39// CHECK2: NEEDED Shared library: [shared1] 40// CHECK2-NOT: NEEDED Shared library: [shared2] 41// CHECK2-NOT: NEEDED Shared library: [shared3] 42 43.global _start 44_start: 45.data 46.long bar 47.long zed 48.weak baz 49 call baz 50