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

Sunho Kim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 08:02:41 PDT 2022


sunho updated this revision to Diff 446161.

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
@@ -49,6 +49,7 @@
 private:
   enum COFFX86RelocationKind {
     COFFAddr32NB,
+    COFFAddr64,
     COFFRel32,
     COFFRel32_1,
   };
@@ -58,6 +59,8 @@
     switch (Type) {
     case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_ADDR32NB:
       return COFFAddr32NB;
+    case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_ADDR64:
+      return COFFAddr64;
     case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_REL32:
       return COFFRel32;
     case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_REL32_1:
@@ -130,6 +133,11 @@
       Addend = *reinterpret_cast<const support::little32_t *>(FixupPtr);
       break;
     }
+    case COFFAddr64: {
+      Kind = x86_64::Pointer64;
+      Addend = *reinterpret_cast<const support::little64_t *>(FixupPtr);
+      break;
+    }
     case COFFRel32: {
       Kind = x86_64::PCRel32;
       Addend = *reinterpret_cast<const support::little32_t *>(FixupPtr);


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


More information about the llvm-commits mailing list