[PATCH] D38712: [ELF] Try to not emit weird diagnostics on undefined symbols

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 11:37:36 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL315487: [ELF] Try to not emit weird diagnostics on undefined symbols. (authored by davide).

Changed prior to commit:
  https://reviews.llvm.org/D38712?vs=118305&id=118656#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38712

Files:
  lld/trunk/ELF/Relocations.cpp
  lld/trunk/test/ELF/Inputs/undefined-error.s
  lld/trunk/test/ELF/pr34872.s


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 at 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
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<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);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38712.118656.patch
Type: text/x-patch
Size: 1706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171011/a6952b37/attachment.bin>


More information about the llvm-commits mailing list