Index: lld/ELF/Relocations.cpp =================================================================== --- lld/ELF/Relocations.cpp +++ lld/ELF/Relocations.cpp @@ -955,6 +955,12 @@ (sec.name == ".got2" || sec.name == ".toc")) return false; + // The "gcc_except_table" can have relocations to discarded sections. + // Don't error out. + if (cast(sym).discardedSecIdx != 0 && + sec.name == ".gcc_except_table") + return false; + bool isWarning = (config->unresolvedSymbols == UnresolvedPolicy::Warn && canBeExternal) || config->noinhibitExec; Index: lld/test/ELF/comdat-discarded-no-error.s =================================================================== --- /dev/null +++ lld/test/ELF/comdat-discarded-no-error.s @@ -0,0 +1,18 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t1.o +# RUN: echo '.section .text.foo,"axG",@progbits,foo,comdat; .globl foo; foo:' |\ +# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %t2.o +# RUN: echo '.section .text.foo,"axG",@progbits,foo,comdat; .globl bar; bar:' |\ +# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %t3.o + +# RUN: ld.lld %t2.o %t3.o %t1.o -o /dev/null 2>&1 + +.globl _start +_start: + nop + +.section .text.foo,"axG",@progbits,foo,comdat + nop + +.section .gcc_except_table,"a" + .quad .text.foo