50 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o3# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/gc-sections-shared.s -o %t3.o4# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/gc-sections-shared2.s -o %t4.o5# RUN: ld.lld -shared %t2.o -o %t2.so6# RUN: ld.lld -shared %t3.o -o %t3.so7# RUN: ld.lld -shared %t4.o -o %t4.so8# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o9# RUN: ld.lld --gc-sections --export-dynamic-symbol foo -o %t %t.o --as-needed %t2.so %t3.so %t4.so10# RUN: llvm-readelf -d --dyn-symbols %t | FileCheck %s11 12# This test the property that we have a needed line for every undefined.13# It would also be OK to keep bar2 and the need for %t2.so14# At the same time, weak symbols should not cause adding DT_NEEDED;15# this case is checked with symbol qux and %t4.so.16 17# CHECK-NOT: NEEDED18# CHECK: (NEEDED) Shared library: [{{.*}}3.so]19# CHECK-NOT: NEEDED20 21# CHECK-DAG: FUNC WEAK DEFAULT UND qux22# CHECK-DAG: NOTYPE GLOBAL DEFAULT 6 bar23# CHECK-DAG: FUNC GLOBAL DEFAULT UND baz24# CHECK-DAG: NOTYPE GLOBAL DEFAULT 6 foo25 26# Test with %t.o at the end too.27# RUN: ld.lld --gc-sections --export-dynamic-symbol foo -o %t --as-needed %t2.so %t3.so %t4.so %t.o28# RUN: llvm-readelf --dynamic-table --dyn-symbols %t | FileCheck --check-prefix=CHECK %s29 30.section .text.foo, "ax"31.globl foo32foo:33.long bar - .34 35.section .text.bar, "ax"36.globl bar37bar:38ret39 40.section .text._start, "ax"41.globl _start42.weak qux43_start:44.long baz - .45.long qux - .46ret47 48.section .text.unused, "ax"49.long bar2 - .50