[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / linkerscript / relocatable-discard.s
bloba8c00046405ae49b19d49bfecdd8c2e68de5e5f5
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3 # RUN: echo "SECTIONS { /DISCARD/ : { *(.discard.*) }}" > %t.script
4 # RUN: ld.lld -o %t --script %t.script -r %t.o
5 # RUN: llvm-readobj --sections %t | FileCheck %s
7 ## Test shows that we do not crash after discarding the .discard.foo with -r.
8 ## Previously it happened because of 2 reasons:
9 ## 1) .rela.discard.foo was not handled properly and was not discarded.
10 ## Remaining reference was invalid and caused the crash.
11 ## 2) Third-party section .debug_info referencing discarded section
12 ## did not handle this case properly and tried to apply the
13 ## relocation instead of ignoring it.
15 # CHECK-NOT: .discard
17 .section .discard.foo,"ax"
18 callq fn@PLT
20 .section .debug_info,"",@progbits
21 .long .discard.foo