[llvm] 7b58259 - [RuntimeDyld][ELF] Fix off-by-1 issues in R_AARCH64_ABS{16,32} overflow checks

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 5 06:52:59 PDT 2023


Author: Fangrui Song
Date: 2023-04-05T06:52:54-07:00
New Revision: 7b58259481417bb22d144a9c12ee8f4fb0a046e0

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

LOG: [RuntimeDyld][ELF] Fix off-by-1 issues in R_AARCH64_ABS{16,32} overflow checks

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
index 282c357f2de2c..300bb1d73e529 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -426,13 +426,13 @@ void RuntimeDyldELF::resolveAArch64Relocation(const SectionEntry &Section,
     break;
   case ELF::R_AARCH64_ABS16: {
     uint64_t Result = Value + Addend;
-    assert(static_cast<int64_t>(Result) >= INT16_MIN && Result < UINT16_MAX);
+    assert(static_cast<int64_t>(Result) >= INT16_MIN && Result <= UINT16_MAX);
     write(isBE, TargetPtr, static_cast<uint16_t>(Result & 0xffffU));
     break;
   }
   case ELF::R_AARCH64_ABS32: {
     uint64_t Result = Value + Addend;
-    assert(static_cast<int64_t>(Result) >= INT32_MIN && Result < UINT32_MAX);
+    assert(static_cast<int64_t>(Result) >= INT32_MIN && Result <= UINT32_MAX);
     write(isBE, TargetPtr, static_cast<uint32_t>(Result & 0xffffffffU));
     break;
   }


        


More information about the llvm-commits mailing list