[llvm] 1deaa9b - [JITLink][ELF][AArch64] Implement R_AARCH64_ABS64 relocation type.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 7 17:56:15 PDT 2022
Author: Lang Hames
Date: 2022-06-07T17:56:10-07:00
New Revision: 1deaa9b8bdb6c6169ad3fea95e0f2c6c8e99dd01
URL: https://github.com/llvm/llvm-project/commit/1deaa9b8bdb6c6169ad3fea95e0f2c6c8e99dd01
DIFF: https://github.com/llvm/llvm-project/commit/1deaa9b8bdb6c6169ad3fea95e0f2c6c8e99dd01.diff
LOG: [JITLink][ELF][AArch64] Implement R_AARCH64_ABS64 relocation type.
Implement R_AARCH64_ABS64 relocation entry. This relocation type is generated
when creating a static function pointer to symbol.
Reviewed By: lhames, sgraenitz
Differential Revision: https://reviews.llvm.org/D126658
Added:
Modified:
llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_relocations.s
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
index 5a24a69f9fd08..8ce1f67d63cf8 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
@@ -54,6 +54,7 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
ELFLdSt32Abs12,
ELFLdSt64Abs12,
ELFLdSt128Abs12,
+ ELFAbs64,
};
static Expected<ELFAArch64RelocationKind>
@@ -76,6 +77,8 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
return ELFLdSt64Abs12;
case ELF::R_AARCH64_LDST128_ABS_LO12_NC:
return ELFLdSt128Abs12;
+ case ELF::R_AARCH64_ABS64:
+ return ELFAbs64;
}
return make_error<JITLinkError>("Unsupported aarch64 relocation:" +
@@ -199,6 +202,10 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
Kind = aarch64::PageOffset12;
break;
}
+ case ELFAbs64: {
+ Kind = aarch64::Pointer64;
+ break;
+ }
};
Edge GE(Kind, Offset, *GraphSymbol, Addend);
@@ -231,6 +238,8 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
return "ELFLdSt64Abs12";
case ELFLdSt128Abs12:
return "ELFLdSt128Abs12";
+ case ELFAbs64:
+ return "ELFAbs64";
default:
return getGenericEdgeKindName(static_cast<Edge::Kind>(R));
}
diff --git a/llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_relocations.s b/llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_relocations.s
index 1a670c2648a8a..7a433e1715ba7 100644
--- a/llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_relocations.s
+++ b/llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_relocations.s
@@ -1,5 +1,6 @@
# RUN: rm -rf %t && mkdir -p %t
-# RUN: llvm-mc -triple=aarch64-unknown-linux-gnu -relax-relocations=false -position-independent -filetype=obj -o %t/elf_reloc.o %s
+# RUN: llvm-mc -triple=aarch64-unknown-linux-gnu -relax-relocations=false \
+# RUN: -position-independent -filetype=obj -o %t/elf_reloc.o %s
# RUN: llvm-jitlink -noexec -check %s %t/elf_reloc.o
.text
@@ -113,6 +114,15 @@ test_str_64bit:
str x0, [x1, :lo12:named_data]
.size test_str_64bit, .-test_str_64bit
+# Check R_AARCH64_ABS64 relocation of a function pointer to local symbol
+#
+# jitlink-check: *{8}local_func_addr_quad = named_func
+ .globl local_func_addr_quad
+ .p2align 3
+local_func_addr_quad:
+ .xword named_func
+ .size local_func_addr_quad, 8
+
.globl named_data
.p2align 4
.type named_data, at object
@@ -120,3 +130,10 @@ named_data:
.quad 0x2222222222222222
.quad 0x3333333333333333
.size named_data, .-named_data
+
+ .globl named_func
+ .p2align 2
+ .type named_func, at function
+named_func:
+ ret
+ .size named_func, .-named_func
More information about the llvm-commits
mailing list