[PATCH] D55968: Show a user-friendly error message for a missing vtable symbol.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 20 15:51:11 PST 2018


ruiu created this revision.
ruiu added a reviewer: MaskRay.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

GNU gold has this error message.


https://reviews.llvm.org/D55968

Files:
  lld/ELF/Relocations.cpp
  lld/test/ELF/undef.s


Index: lld/test/ELF/undef.s
===================================================================
--- lld/test/ELF/undef.s
+++ lld/test/ELF/undef.s
@@ -20,6 +20,9 @@
 # CHECK: >>> referenced by undef.s
 # CHECK: >>>               {{.*}}:(.text+0x10)
 
+# CHECK: error: undefined symbol: vtable for Foo
+# CHECK: the vtable symbol may be undefined because the class is missing its key function
+
 # CHECK: error: undefined symbol: zed2
 # CHECK: >>> referenced by {{.*}}.o:(.text+0x0) in archive {{.*}}2.a
 
@@ -60,3 +63,4 @@
   call bar
   call zed1
   call _Z3fooi
+  call _ZTV3Foo
Index: lld/ELF/Relocations.cpp
===================================================================
--- lld/ELF/Relocations.cpp
+++ lld/ELF/Relocations.cpp
@@ -663,6 +663,10 @@
     Msg += Src + "\n>>>               ";
   Msg += Sec.getObjMsg(Offset);
 
+  if (Sym.getName().startswith("_ZTV"))
+    Msg += "\nthe vtable symbol may be undefined because the class is "
+           "missing its key function";
+
   if ((Config->UnresolvedSymbols == UnresolvedPolicy::Warn && CanBeExternal) ||
       Config->NoinhibitExec) {
     warn(Msg);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55968.179187.patch
Type: text/x-patch
Size: 1119 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181220/86258366/attachment.bin>


More information about the llvm-commits mailing list