[PATCH] D153494: Detect out of range jumps further than 2^32 bytes
Daniel Hoekwater via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 21 21:05:41 PDT 2023
dhoekwater created this revision.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
dhoekwater requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
On AArch64, object files may be greater than 2^32 bytes. If an
offset is greater than the max value of a 32-bit unsigned integer,
LLVM silently truncates the offset. Instead, make it return an
error.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153494
Files:
llvm/lib/MC/MCAssembler.cpp
llvm/test/MC/AArch64/fixup-out-of-range-64-bit.s
Index: llvm/test/MC/AArch64/fixup-out-of-range-64-bit.s
===================================================================
--- /dev/null
+++ llvm/test/MC/AArch64/fixup-out-of-range-64-bit.s
@@ -0,0 +1,10 @@
+// RUN: not llvm-mc -triple aarch64--none-eabi -filetype obj < %s -o /dev/null 2>&1 | FileCheck %s
+
+distant:
+ .byte 0
+
+ .space 1<<32
+ .balign 8
+
+// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: fixup value out of range
+ b distant
\ No newline at end of file
Index: llvm/lib/MC/MCAssembler.cpp
===================================================================
--- llvm/lib/MC/MCAssembler.cpp
+++ llvm/lib/MC/MCAssembler.cpp
@@ -273,7 +273,7 @@
"FKF_IsAlignedDownTo32Bits is only allowed on PC-relative fixups!");
if (IsPCRel) {
- uint32_t Offset = Layout.getFragmentOffset(DF) + Fixup.getOffset();
+ uint64_t Offset = Layout.getFragmentOffset(DF) + Fixup.getOffset();
// A number of ARM fixups in Thumb mode require that the effective PC
// address be determined as the 32-bit aligned version of the actual offset.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153494.533464.patch
Type: text/x-patch
Size: 1059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230622/e83880fe/attachment.bin>
More information about the llvm-commits
mailing list