[PATCH] D18056: Compute value of local symbol with getVA.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 10 12:19:14 PST 2016


ruiu added a comment.

This is very similar to a change that I have locally.


================
Comment at: ELF/Symbols.cpp:79-82
@@ +78,6 @@
+
+    // PPC64 has a special relocation representing the TOC base pointer
+    // that does not have a corresponding symbol.
+    if (Config->EMachine == EM_PPC64 && !SC)
+      return getPPC64TocBase();
+
----------------
This covers a special case, and I don't think absence of the input section always means that we want TocBase. Can you move this InputSectionBase::relocate like this?

    // PPC64 has a special relocation representing the TOC base pointer
    // that does not have a corresponding symbol.
    if (Config->EMachine == EM_PPC64 && RI.getType(false) == R_PPC64_TOC) {
      uintX_t SymVA = getPPC64TocBase() + A;
      Target->relocateOne(BufLoc, BufEnd, Type, AddrLoc, SymVA, 0);
      continue;
    }

================
Comment at: ELF/Symbols.cpp:95-98
@@ +94,6 @@
+             Out<ELFT>::TlsPhdr->p_vaddr;
+    if (Sym.getType() == STT_SECTION) {
+      Offset += Addend;
+      Addend = 0;
+    }
+    return SC->OutSec->getVA() + SC->getOffset(Offset);
----------------
In this case Addend is taken into consideration.

================
Comment at: ELF/Symbols.cpp:108
@@ +107,3 @@
+SymbolBody::getVA(typename ELFFile<ELFT>::uintX_t Addend) const {
+  return getSymVA<ELFT>(*this, Addend) + Addend;
+}
----------------
... and adding an addend again? Is this correct?


http://reviews.llvm.org/D18056





More information about the llvm-commits mailing list