Index: lld/trunk/ELF/Relocations.cpp =================================================================== --- lld/trunk/ELF/Relocations.cpp +++ lld/trunk/ELF/Relocations.cpp @@ -859,9 +859,14 @@ // symbols here means that we report undefined symbols only when // they have relocations pointing to them. We don't care about // undefined symbols that are in dead-stripped sections. - if (!Body.isLocal() && Body.isUndefined() && !Body.symbol()->isWeak()) + if (!Body.isLocal() && Body.isUndefined() && !Body.symbol()->isWeak()) { reportUndefined(Body, Sec, Rel.r_offset); + // If we report an undefined, and we have an error, go on. + if (ErrorCount) + continue; + } + RelExpr Expr = Target->getRelExpr(Type, Body, *Sec.File, Sec.Data.begin() + Rel.r_offset); Index: lld/trunk/test/ELF/Inputs/undefined-error.s =================================================================== --- lld/trunk/test/ELF/Inputs/undefined-error.s +++ lld/trunk/test/ELF/Inputs/undefined-error.s @@ -0,0 +1 @@ +callq fmod@PLT Index: lld/trunk/test/ELF/pr34872.s =================================================================== --- lld/trunk/test/ELF/pr34872.s +++ lld/trunk/test/ELF/pr34872.s @@ -0,0 +1,14 @@ +# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t.o +# RUN: llvm-mc %p/Inputs/undefined-error.s -filetype=obj \ +# RUN: -triple=x86_64-pc-linux -o %t2.o +# RUN: ld.lld -shared %t2.o -o %t2.so +# RUN: not ld.lld %t2.so %t.o 2>&1 | FileCheck %s + +# CHECK: undefined symbol: fmod +# Check we're not emitting other diagnostics for this symbol. +# CHECK-NOT: fmod + +.global main + +main: + callq fmod