[llvm] [JITLink][AArch32] Fix applyFixup Data_Pointer32 range with unsigned write (PR #71784)
Eymen Ünay via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 8 23:35:26 PST 2023
https://github.com/eymay created https://github.com/llvm/llvm-project/pull/71784
Data_Pointer32 when used as a pointer was giving out of range errors.
This fixes it by checking the value as unsigned 32 bits and writing
it as an unsigned value. This will allow using Data_Pointer32 for
GOT/PLT as well.
>From cd9d976b5a66a6ac94a1378fa137b99a3602a229 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eymen=20=C3=9Cnay?= <eymenunay at outlook.com>
Date: Sat, 4 Nov 2023 19:44:36 +0300
Subject: [PATCH] [JITLink][AArch32] Fix applyFixup Data_Pointer32 range with
unsigned write
Data_Pointer32 when used as a pointer was giving out of range errors.
This fixes it by checking the value as unsigned 32 bits and writing
it as an unsigned value. This will allow using Data_Pointer32 for
GOT/PLT as well.
---
llvm/lib/ExecutionEngine/JITLink/aarch32.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
index 4aed64966654420..1fee091a5337138 100644
--- a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
@@ -430,9 +430,12 @@ Error applyFixupData(LinkGraph &G, Block &B, const Edge &E) {
}
case Data_Pointer32: {
int64_t Value = TargetAddress + Addend;
- if (!isInt<32>(Value))
+ if (!isUInt<32>(Value))
return makeTargetOutOfRangeError(G, B, E);
- Write32(Value);
+ if (LLVM_LIKELY(G.getEndianness() == llvm::endianness::little))
+ endian::write32<llvm::endianness::little>(FixupPtr, Value);
+ else
+ endian::write32<llvm::endianness::big>(FixupPtr, Value);
return Error::success();
}
default:
More information about the llvm-commits
mailing list