[PATCH] [RuntimeDyldELF] Improve GOT support

Lang Hames lhames at gmail.com
Mon Apr 6 12:51:10 PDT 2015


REPOSITORY
  rL LLVM

================
Comment at: lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:255-258
@@ -267,3 +254,6 @@
     uint64_t FinalAddress = Section.LoadAddress + Offset;
-    int64_t RealOffset = Placeholder + Value + Addend - FinalAddress;
+    int64_t RealOffset = Value + Addend - FinalAddress;
+    // Don't add the placeholder if this is a stub
+    if (Offset < Section.Size)
+      RealOffset += Placeholder;
     assert(RealOffset <= INT32_MAX && RealOffset >= INT32_MIN);
----------------
loladiro wrote:
> lhames wrote:
> > Would it be better to zero out the GOT entry when it's reserved so that you don't need to special-case the placeholder logic here?
> No, that doesn't work because the placeholder pull values out of the original (unrelocated) object file, which does not have the stub. The better direction to go is to encode everything that's needed into the Addend, but that's a separate and more invasive change.
Ahh, of course. This is another good argument for getting rid of our reliance on the original file.

Given this, your existing scheme looks good to me.

http://reviews.llvm.org/D8813

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list