[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / as-needed-not-in-regular.s
blobcd7efa6d2688e92fb67873500cd080e6f473be97
1 # REQUIRES: x86
3 # RUN: echo '.globl a1, a2; .type a1, @function; .type a2, @function; a1: a2: ret' | \
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %ta.o
5 # RUN: ld.lld %ta.o --shared --soname=a.so -o %ta.so
7 # RUN: echo '.globl b; .type b, @function; b: jmp a1@PLT' | \
8 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %tb.o
9 # RUN: ld.lld %tb.o %ta.so --shared --soname=b.so -o %tb.so
11 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
12 # RUN: ld.lld %t.o %tb.so --as-needed %ta.so -o %t
13 # RUN: llvm-readelf -d %t | FileCheck %s
15 # RUN: ld.lld %t.o %tb.so --as-needed %ta.so --gc-sections -o %t
16 # RUN: llvm-readelf -d %t | FileCheck %s
18 # The symbol a1 (defined in a.so) is not referenced by a regular object,
19 # the reference to a2 is weak, don't add a DT_NEEDED entry for a.so.
20 # CHECK-NOT: a.so
22 # RUN: ld.lld %t.o %tb.so --as-needed %ta.so --no-as-needed %ta.so -o %t
23 # RUN: llvm-readelf -d %t | FileCheck %s -check-prefix=NEEDED
25 # a.so is needed because one of its occurrences is needed.
26 # NEEDED: a.so
28 .global _start
29 .weak a2
30 _start:
31 jmp b@PLT
32 jmp a2