[llvm] 049fd21 - [JITLink][COFF][x86_64] Implement ADDR64 relocation.
Sunho Kim via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 29 00:32:16 PDT 2022
Author: Sunho Kim
Date: 2022-07-29T16:32:07+09:00
New Revision: 049fd21b42550be656d850ea02fe8690d97a43db
URL: https://github.com/llvm/llvm-project/commit/049fd21b42550be656d850ea02fe8690d97a43db
DIFF: https://github.com/llvm/llvm-project/commit/049fd21b42550be656d850ea02fe8690d97a43db.diff
LOG: [JITLink][COFF][x86_64] Implement ADDR64 relocation.
Implements ADDR64 relocation using x86_64 edge kind.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D130178
Added:
Modified:
llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
index 1ff64badc887..7dd63bb2aa62 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
@@ -29,6 +29,7 @@ namespace {
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 @@ class COFFLinkGraphBuilder_x86_64 : public COFFLinkGraphBuilder {
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 @@ class COFFLinkGraphLowering_x86_64 {
E.setKind(x86_64::PCRel32);
break;
}
+ case EdgeKind_coff_x86_64::Pointer64: {
+ E.setKind(x86_64::Pointer64);
+ break;
+ }
default:
break;
}
@@ -221,6 +231,8 @@ const char *getCOFFX86RelocationKindName(Edge::Kind R) {
return "PCRel32";
case Pointer32NB:
return "Pointer32NB";
+ case Pointer64:
+ return "Pointer64";
default:
return x86_64::getEdgeKindName(R);
}
diff --git a/llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s b/llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s
index 60bad11803eb..dd3f53d899c7 100644
--- a/llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s
+++ b/llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s
@@ -55,6 +55,18 @@ test_rel32_data:
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;
More information about the llvm-commits
mailing list