[PATCH] D126387: [JITLINK][AARCH64] Fix overflow range of Page21

Sunho Kim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 25 08:26:02 PDT 2022


sunho created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
sunho requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Allowed range for Page21 relocation is -2^32 <= X < 2^32 in both ELF and MachO.

https://github.com/llvm/llvm-project/blob/09c2b7c35af8c4bad39f03e9f60df8bd07323028/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h#L210 (MachO)

ELF for the ARM ® 64-bit Architecture (AArch64) Table 4-9 (ELF)


https://reviews.llvm.org/D126387

Files:
  llvm/include/llvm/ExecutionEngine/JITLink/aarch64.h


Index: llvm/include/llvm/ExecutionEngine/JITLink/aarch64.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/JITLink/aarch64.h
+++ llvm/include/llvm/ExecutionEngine/JITLink/aarch64.h
@@ -113,7 +113,7 @@
         FixupAddress.getValue() & ~static_cast<uint64_t>(4096 - 1);
 
     int64_t PageDelta = TargetPage - PCPage;
-    if (PageDelta < -(1 << 30) || PageDelta > ((1 << 30) - 1))
+    if (!isInt<33>(PageDelta))
       return makeTargetOutOfRangeError(G, B, E);
 
     uint32_t RawInstr = *(ulittle32_t *)FixupPtr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126387.432008.patch
Type: text/x-patch
Size: 575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220525/9e22428e/attachment.bin>


More information about the llvm-commits mailing list