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.
17 .section .discard.foo,"ax"
20 .section .debug_info,"",@progbits