[compiler-rt] 5a48a82 - [compiler-rt] Fix interception_win.cpp arm64 instruction lengths

Puyan Lotfi via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 20:03:35 PDT 2023


Author: Farzon Lotfi
Date: 2023-09-12T22:43:51-04:00
New Revision: 5a48a824aa0cf383cc8201d04c0a37ab45912a8c

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

LOG: [compiler-rt] Fix interception_win.cpp arm64 instruction lengths

Updates GetInstructionSize to account for arm64 instruction sizes.

ARM64 instruction are always 4 bytes long but GetInstructionSize in
interception_win.cpp assumes x86_64 which has mixed sizes.

Fix is for: https://github.com/llvm/llvm-project/issues/64319

Before the changeclang_rt.asan_dynamic-aarch64.dll would crash at:
OverrideFunction -> OverrideFunctionWithHotPatch -> GetInstructionSize:825

After the change:
dllthunkintercept -> dllthunkgetrealaddressordie -> InternalGetProcAddress

Added: 
    

Modified: 
    compiler-rt/lib/interception/interception_win.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/interception/interception_win.cpp b/compiler-rt/lib/interception/interception_win.cpp
index 00c317510e42087..b2ba40902347f46 100644
--- a/compiler-rt/lib/interception/interception_win.cpp
+++ b/compiler-rt/lib/interception/interception_win.cpp
@@ -457,6 +457,11 @@ static const u8 kPrologueWithShortJump2[] = {
 
 // Returns 0 on error.
 static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
+#if SANITIZER_ARM64
+  // An ARM64 instruction is 4 bytes long.
+  return 4;
+#endif
+
 #if SANITIZER_WINDOWS64
   if (memcmp((u8*)address, kPrologueWithShortJump1,
              sizeof(kPrologueWithShortJump1)) == 0 ||


        


More information about the llvm-commits mailing list