45 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o3# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/comdat-discarded-reloc.s -o %t2.o4# RUN: ld.lld -gc-sections --noinhibit-exec %t2.o %t.o -o /dev/null5# RUN: ld.lld -r %t2.o %t.o -o %t 2>&1 | FileCheck --check-prefix=WARN %s6# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s7 8## ELF spec doesn't allow a relocation to point to a deduplicated9## COMDAT section. Unfortunately this happens in practice (e.g. .eh_frame)10## Test case checks we do not crash.11 12# WARN: warning: relocation refers to a discarded section: .text.bar113# WARN-NEXT: >>> referenced by {{.*}}.o:(.rela.text.bar2+0x0)14# WARN-NOT: warning15 16# RELOC: .rela.eh_frame {17# RELOC-NEXT: R_X86_64_NONE18# RELOC-NEXT: }19# RELOC-NEXT: .rela.debug_foo {20# RELOC-NEXT: R_X86_64_NONE21# RELOC-NEXT: }22# RELOC-NEXT: .rela.gcc_except_table {23# RELOC-NEXT: R_X86_64_NONE24# RELOC-NEXT: }25 26.globl group27group:28.section .text.bar1,"aG",@progbits,group,comdat29 30## .text.bar1 in this file is discarded. Warn on the relocation.31.section .text.bar2,"ax"32.globl bar33bar:34 .quad .text.bar135 36## Don't warn on .eh_frame, .debug*, .zdebug*, or .gcc_except_table37.section .eh_frame,"a",@unwind38 .quad .text.bar139 40.section .debug_foo41 .quad .text.bar142 43.section .gcc_except_table,"a"44 .quad .text.bar145