[lld] r315487 - [ELF] Try to not emit weird diagnostics on undefined symbols.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 11 11:37:24 PDT 2017
Author: davide
Date: Wed Oct 11 11:37:24 2017
New Revision: 315487
URL: http://llvm.org/viewvc/llvm-project?rev=315487&view=rev
Log:
[ELF] Try to not emit weird diagnostics on undefined symbols.
Fixes PR34872.
Differential Revision: https://reviews.llvm.org/D38712
Added:
lld/trunk/test/ELF/Inputs/undefined-error.s
lld/trunk/test/ELF/pr34872.s
Modified:
lld/trunk/ELF/Relocations.cpp
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=315487&r1=315486&r2=315487&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Oct 11 11:37:24 2017
@@ -859,9 +859,14 @@ static void scanRelocs(InputSectionBase
// 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<ELFT>(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);
Added: lld/trunk/test/ELF/Inputs/undefined-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/undefined-error.s?rev=315487&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/undefined-error.s (added)
+++ lld/trunk/test/ELF/Inputs/undefined-error.s Wed Oct 11 11:37:24 2017
@@ -0,0 +1 @@
+callq fmod at PLT
Added: lld/trunk/test/ELF/pr34872.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/pr34872.s?rev=315487&view=auto
==============================================================================
--- lld/trunk/test/ELF/pr34872.s (added)
+++ lld/trunk/test/ELF/pr34872.s Wed Oct 11 11:37:24 2017
@@ -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
More information about the llvm-commits
mailing list