[compiler-rt] [ASan][Windows] Fix rip-relative instruction replacement (PR #68432)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 9 14:24:19 PDT 2023


================
@@ -726,16 +726,22 @@ static bool CopyInstructions(uptr to, uptr from, size_t size) {
     size_t instruction_size = GetInstructionSize(from + cursor, &rel_offset);
     if (!instruction_size)
       return false;
-    _memcpy((void*)(to + cursor), (void*)(from + cursor),
+    _memcpy((void *)(to + cursor), (void *)(from + cursor),
             (size_t)instruction_size);
     if (rel_offset) {
-      uptr delta = to - from;
-      uptr relocated_offset = *(u32*)(to + cursor + rel_offset) - delta;
-#if SANITIZER_WINDOWS64
-      if (relocated_offset + 0x80000000U >= 0xFFFFFFFFU)
+#  if SANITIZER_WINDOWS64
----------------
vitalybuka wrote:

maybe `if constexpr (SANITIZER_WINDOWS64)` to compile it always

https://github.com/llvm/llvm-project/pull/68432


More information about the llvm-commits mailing list