[PATCH] D28398: Expand comment and error message

Rafael Ávila de Espíndola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 6 05:58:50 PST 2017


rafael created this revision.
rafael added a reviewer: ruiu.
rafael added a subscriber: llvm-commits.

https://reviews.llvm.org/D28398

Files:
  ELF/Relocations.cpp
  test/ELF/copy-errors.s


Index: test/ELF/copy-errors.s
===================================================================
--- test/ELF/copy-errors.s
+++ test/ELF/copy-errors.s
@@ -9,7 +9,8 @@
 
 
 call bar
-// CHECK: {{.*}}.o:(.text+0x1): cannot preempt symbol 'bar' defined in {{.*}}.so
+// CHECK: {{.*}}.o:(.text+0x1): cannot preempt non-default visibility symbol 'bar' defined in {{.*}}.so
+// CHECK-NEXT: The executable has to use a got or plt to refer to it.
 
 call zed
 // CHECK: symbol 'zed' defined in {{.*}}.so is missing type
Index: ELF/Relocations.cpp
===================================================================
--- ELF/Relocations.cpp
+++ ELF/Relocations.cpp
@@ -464,8 +464,14 @@
     return Expr;
   }
   if (Body.getVisibility() != STV_DEFAULT) {
-    error(S.getLocation(RelOff) + ": cannot preempt symbol '" + toString(Body) +
-          "' defined in " + toString(Body.File));
+    // Default visibility is the only one that allows us to preempt the symbol
+    // with a dummy plt or copy relocation. If the symbol has any other
+    // visibility the .so can refer to it directly and the dynamic linker will
+    // not be able to do anything about it.
+    error(S.getLocation(RelOff) +
+          ": cannot preempt non-default visibility symbol '" + toString(Body) +
+          "' defined in " + toString(Body.File) +
+          ".\n The executable has to use a got or plt to refer to it.");
     return Expr;
   }
   if (Body.isObject()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28398.83360.patch
Type: text/x-patch
Size: 1447 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170106/3ba2c6b5/attachment.bin>


More information about the llvm-commits mailing list