[llvm] d8cef4f - [MC] Detect out of range jumps further than 2^32 bytes

Daniel Hoekwater via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 22 15:00:08 PDT 2023


Author: Daniel Hoekwater
Date: 2023-06-22T21:56:22Z
New Revision: d8cef4f8fa9c122fb86d1953a754b37bdcfeb053

URL: https://github.com/llvm/llvm-project/commit/d8cef4f8fa9c122fb86d1953a754b37bdcfeb053
DIFF: https://github.com/llvm/llvm-project/commit/d8cef4f8fa9c122fb86d1953a754b37bdcfeb053.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/MC/MCAssembler.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index f1853bfe2b92f..17170cb61d34e 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.


        


More information about the llvm-commits mailing list