[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / dso-undef-extract-lazy.s
blob40b0758957d7a5324bc578c2f7e1674c9704297f
1 # REQUIRES: x86
2 # RUN: rm -fr %t && split-file %s %t
4 ## Build an object with a trivial main function
5 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/main.s -o %t1.o
7 ## Build %t.a which defines a global 'foo'
8 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/archive.s -o %t2.o
9 # RUN: rm -f %t2.a
10 # RUN: llvm-ar rc %t2.a %t2.o
12 ## Build %t.so that has a reference to 'foo'
13 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/shlib.s -o %t3.o
14 # RUN: ld.lld %t3.o -o %t3.so -shared
16 ## Test that 'foo' from %t2.a is fetched to define 'foo' needed by %t3.so.
17 ## Test both cases where the archive is before or after the shared library in
18 ## link order.
20 # RUN: ld.lld %t1.o %t2.a %t3.so -o %t.exe
21 # RUN: llvm-readelf --dyn-symbols %t.exe | FileCheck %s --check-prefix=CHECK-FETCH
23 # RUN: ld.lld %t1.o %t3.so %t2.a -o %t.exe
24 # RUN: llvm-readelf --dyn-symbols %t.exe | FileCheck %s --check-prefix=CHECK-FETCH
26 # CHECK-FETCH: GLOBAL DEFAULT {{[0-9]+}} foo
28 #--- main.s
29 .text
30 .globl _start
31 .type _start,@function
32 _start:
33 ret
35 #--- archive.s
36 .global foo
37 foo:
39 #--- shlib.s
40 .global foo