Index: lld/trunk/ELF/InputFiles.cpp =================================================================== --- lld/trunk/ELF/InputFiles.cpp +++ lld/trunk/ELF/InputFiles.cpp @@ -214,6 +214,11 @@ fatal("Invalid relocated section index"); InputSectionBase *RelocatedSection = Sections[RelocatedSectionIndex]; + // Strictly speaking, a relocation section must be included in the + // group of the section it relocates. However, LLVM 3.3 and earlier + // would fail to do so, so we gracefully handle that case. + if (RelocatedSection == &InputSection::Discarded) + continue; if (!RelocatedSection) fatal("Unsupported relocation reference"); if (auto *S = dyn_cast>(RelocatedSection)) { Index: lld/trunk/test/ELF/llvm33-rela-outside-group.s =================================================================== --- lld/trunk/test/ELF/llvm33-rela-outside-group.s +++ lld/trunk/test/ELF/llvm33-rela-outside-group.s @@ -0,0 +1,11 @@ +// Input file generated with: +// llvm33/llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %S/Inputs/llvm33-rela-outside-group.o +// +// RUN: ld.lld -shared %S/Inputs/llvm33-rela-outside-group.o %S/Inputs/llvm33-rela-outside-group.o + + .global bar + .weak _Z3fooIiEvv + + .section .text._Z3fooIiEvv,"axG",@progbits,_Z3fooIiEvv,comdat +_Z3fooIiEvv: + callq bar