[PATCH] D23690: [ELF] Improve error reporting for relocations

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 18 13:01:52 PDT 2016


ruiu added inline comments.

================
Comment at: ELF/Relocations.cpp:425-430
@@ -424,4 +424,8 @@
   if (Config->Shared || (Config->Pic && !isRelExpr(Expr))) {
-    error("can't create dynamic relocation " + getRelName(Type) +
-          " against readonly segment");
+    if (!Body.isLocal())
+      error("can't create dynamic relocation " + getRelName(Type) +
+            " against symbol " + Body.getName());
+    else
+      error("can't create dynamic relocation " + getRelName(Type) +
+            " against readonly segment");
     return Expr;
----------------
phosek wrote:
> ruiu wrote:
> > You can call getName() on a local symbol, can't you?
> There is an `assert(!isLocal())` in `SymbolBody::getName()`. The name for local symbols is empty, but it I could use the name offset and find name in the File string table (if it's there), does that sound fine to you?
Ah, right. Please define something like this and use it.

  template <class ELFT>
  static StringRef getLocalSymName(elf::ObjectFile<ELFT> &F, SymbolBody &B) {
    return F.getStringTable().data() + B.getNameOffset();
  }



https://reviews.llvm.org/D23690





More information about the llvm-commits mailing list