[PATCH] D130178: [JITLink][COFF][x86_64] Implement ADDR64 relocation.

Sunho Kim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 29 00:32:26 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG049fd21b4255: [JITLink][COFF][x86_64] Implement ADDR64 relocation. (authored by sunho).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130178

Files:
  llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
  llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s


Index: llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s
===================================================================
--- llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s
+++ llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s
@@ -55,6 +55,18 @@
 test_call_dllimport:
 	callq	*__imp_extern_out_of_range32(%rip)
 
+# Check IMAGE_REL_AMD64_ADDR64 sets address of symbol to the fixup position.
+# jitlink-check: *{8}(test_addr64) = named_data
+	.text
+	.def named_func;
+	.scl 2;
+	.type 32;
+	.endef
+	.globl test_addr64
+	.p2align 4, 0x90
+test_addr64:
+	.quad named_data
+
 # Local named data/func that is used in conjunction with other test cases
 	.text
 	.def named_func;
Index: llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
===================================================================
--- llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
+++ llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
@@ -29,6 +29,7 @@
 enum EdgeKind_coff_x86_64 : Edge::Kind {
   PCRel32 = x86_64::FirstPlatformRelocation,
   Pointer32NB,
+  Pointer64,
 };
 
 class COFFJITLinker_x86_64 : public JITLinker<COFFJITLinker_x86_64> {
@@ -114,6 +115,11 @@
       Addend -= 1;
       break;
     }
+    case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_ADDR64: {
+      Kind = EdgeKind_coff_x86_64::Pointer64;
+      Addend = *reinterpret_cast<const support::little64_t *>(FixupPtr);
+      break;
+    }
     default: {
       return make_error<JITLinkError>("Unsupported x86_64 relocation:" +
                                       formatv("{0:d}", Rel.getType()));
@@ -158,6 +164,10 @@
           E.setKind(x86_64::PCRel32);
           break;
         }
+        case EdgeKind_coff_x86_64::Pointer64: {
+          E.setKind(x86_64::Pointer64);
+          break;
+        }
         default:
           break;
         }
@@ -221,6 +231,8 @@
     return "PCRel32";
   case Pointer32NB:
     return "Pointer32NB";
+  case Pointer64:
+    return "Pointer64";
   default:
     return x86_64::getEdgeKindName(R);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130178.448533.patch
Type: text/x-patch
Size: 2073 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220729/deb91701/attachment.bin>


More information about the llvm-commits mailing list