[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / linkerscript / provide-empty-section.s
blob686d2c1b0b4ecdcd28882b49a30500ce28b19bd5
1 # REQUIRES: x86
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tundefined.o
4 # RUN: echo "foo=42" | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %tdefined.o
5 # RUN: echo "call foo" | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %treference.o
7 # RUN: echo "SECTIONS { .bar : { PROVIDE(foo = .); } }" > %t.script
9 # Case 1: Provided symbol is undefined and not referenced - empty section should be removed.
10 # RUN: ld.lld %tundefined.o -T %t.script -o %t1.elf
11 # RUN: llvm-readobj --sections %t1.elf | FileCheck %s --check-prefix=NOSECTION
13 # Case 2: Provided symbol is undefined and referenced - empty section should not be removed.
14 # RUN: ld.lld %tundefined.o %treference.o -T %t.script -o %t2.elf
15 # RUN: llvm-readobj --sections %t2.elf | FileCheck %s --check-prefix=SECTION
17 # Case 3: Provided symbol is defined and not referenced - empty section should be removed.
18 # RUN: ld.lld %tdefined.o -T %t.script -o %t3.elf
19 # RUN: llvm-readobj --sections %t3.elf | FileCheck %s --check-prefix=NOSECTION
21 # Case 4: Provided symbol is defined and referenced - empty section should not be removed.
22 # RUN: ld.lld %tdefined.o %treference.o -T %t.script -o %t4.elf
23 # RUN: llvm-readobj --sections %t4.elf | FileCheck %s --check-prefix=SECTION
25 .global _start
26 _start:
27 ret
29 # SECTION: .bar
30 # NOSECTION-NOT: .bar