From d8cef4f8fa9c122fb86d1953a754b37bdcfeb053 Mon Sep 17 00:00:00 2001 From: Daniel Hoekwater Date: Thu, 22 Jun 2023 03:56:14 +0000 Subject: [PATCH] [MC] Detect out of range jumps further than 2^32 bytes 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. Differential Revision: https://reviews.llvm.org/D153494 --- llvm/lib/MC/MCAssembler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index f1853bfe2b92..17170cb61d34 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -273,7 +273,7 @@ bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout, "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.