[PATCH] D141746: Fixes handling logic for i386/ELF GOTPC relocation

Kshitij Jain via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 13 21:02:18 PST 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa3e975d42efa: Fixes handling logic for i386/ELF GOTPC relocation (authored by jain98).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141746/new/

https://reviews.llvm.org/D141746

Files:
  llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp


Index: llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
===================================================================
--- llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
+++ llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
@@ -11,14 +11,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/ExecutionEngine/JITLink/ELF_i386.h"
+#include "DefineExternalSectionStartAndEndSymbols.h"
 #include "ELFLinkGraphBuilder.h"
 #include "JITLinkGeneric.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/ExecutionEngine/JITLink/i386.h"
 #include "llvm/Object/ELFObjectFile.h"
 
-#include "DefineExternalSectionStartAndEndSymbols.h"
-
 #define DEBUG_TYPE "jitlink"
 
 using namespace llvm;
@@ -180,9 +179,18 @@
     if (!Kind)
       return Kind.takeError();
 
+    auto FixupAddress = orc::ExecutorAddr(FixupSection.sh_addr) + Rel.r_offset;
     int64_t Addend = 0;
 
-    auto FixupAddress = orc::ExecutorAddr(FixupSection.sh_addr) + Rel.r_offset;
+    switch (*Kind) {
+    case i386::EdgeKind_i386::Delta32: {
+      const char *FixupContent = BlockToFix.getContent().data() +
+                                 (FixupAddress - BlockToFix.getAddress());
+      Addend = *(const support::ulittle32_t *)FixupContent;
+      break;
+    }
+    }
+
     Edge::OffsetT Offset = FixupAddress - BlockToFix.getAddress();
     Edge GE(*Kind, Offset, *GraphSymbol, Addend);
     LLVM_DEBUG({


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141746.489194.patch
Type: text/x-patch
Size: 1426 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230114/411d7a70/attachment.bin>


More information about the llvm-commits mailing list