2 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/comdat-discarded-reloc.s -o %t2.o
4 # RUN: ld.lld -gc-sections --noinhibit-exec %t2.o %t.o -o /dev/null
5 # RUN: ld.lld -r %t2.o %t.o -o %t 2>&1 | FileCheck --check-prefix=WARN %s
6 # RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s
8 ## ELF spec doesn't allow a relocation to point to a deduplicated
9 ## COMDAT section. Unfortunately this happens in practice (e.g. .eh_frame)
10 ## Test case checks we do not crash.
12 # WARN: warning: relocation refers to a discarded section: .text.bar1
13 # WARN-NEXT: >>> referenced by {{.*}}.o:(.rela.text.bar2+0x0)
16 # RELOC: .rela.eh_frame {
17 # RELOC-NEXT: R_X86_64_NONE
19 # RELOC-NEXT: .rela.debug_foo {
20 # RELOC-NEXT: R_X86_64_NONE
22 # RELOC-NEXT: .rela.gcc_except_table {
23 # RELOC-NEXT: R_X86_64_NONE
28 .section .text.bar1,"aG",@progbits,group,comdat
30 ## .text.bar1 in this file is discarded. Warn on the relocation.
31 .section .text.bar2,"ax"
36 ## Don't warn on .eh_frame, .debug*, .zdebug*, or .gcc_except_table
37 .section .eh_frame,"a",@unwind
43 .section .gcc_except_table,"a"