Skip to content

Commit d79aee9

Browse files
farzonlFarzon Lotfi
andauthored
Changes to support running tests for Windows arm64 asan (#66973)
1. Differentiate SANITIZER_WINDOWS64 for x64 and arm64 2. turn off interception tests that expect x86 assembly --------- Co-authored-by: Farzon Lotfi <[email protected]>
1 parent 623cd75 commit d79aee9

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

compiler-rt/lib/interception/interception_win.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ static uptr AllocateMemoryForTrampoline(uptr image_address, size_t size) {
431431
// The following prologues cannot be patched because of the short jump
432432
// jumping to the patching region.
433433

434-
#if SANITIZER_WINDOWS64
434+
// Short jump patterns below are only for x86_64.
435+
# if SANITIZER_WINDOWS_x64
435436
// ntdll!wcslen in Win11
436437
// 488bc1 mov rax,rcx
437438
// 0fb710 movzx edx,word ptr [rax]
@@ -462,7 +463,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
462463
return 4;
463464
#endif
464465

465-
#if SANITIZER_WINDOWS64
466+
# if SANITIZER_WINDOWS_x64
466467
if (memcmp((u8*)address, kPrologueWithShortJump1,
467468
sizeof(kPrologueWithShortJump1)) == 0 ||
468469
memcmp((u8*)address, kPrologueWithShortJump2,
@@ -544,7 +545,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
544545
return 7;
545546
}
546547

547-
#if SANITIZER_WINDOWS64
548+
# if SANITIZER_WINDOWS_x64
548549
switch (*(u8*)address) {
549550
case 0xA1: // A1 XX XX XX XX XX XX XX XX :
550551
// movabs eax, dword ptr ds:[XXXXXXXX]

compiler-rt/lib/interception/tests/interception_win_test.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
#include "gtest/gtest.h"
1616

1717
// Too slow for debug build
18+
// Disabling for ARM64 since testcases are x86/x64 assembly.
1819
#if !SANITIZER_DEBUG
1920
#if SANITIZER_WINDOWS
21+
# if !SANITIZER_WINDOWS_ARM64
2022

21-
#include <stdarg.h>
23+
# include <stdarg.h>
2224

23-
#define WIN32_LEAN_AND_MEAN
24-
#include <windows.h>
25+
# define WIN32_LEAN_AND_MEAN
26+
# include <windows.h>
2527

2628
namespace __interception {
2729
namespace {
@@ -793,5 +795,6 @@ TEST(Interception, EmptyExportTable) {
793795

794796
} // namespace __interception
795797

798+
# endif // !SANITIZER_WINDOWS_ARM64
796799
#endif // SANITIZER_WINDOWS
797800
#endif // #if !SANITIZER_DEBUG

compiler-rt/lib/sanitizer_common/sanitizer_platform.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,14 @@
260260
# define SANITIZER_ARM64 0
261261
#endif
262262

263+
#if SANITIZER_WINDOWS64 && SANITIZER_ARM64
264+
# define SANITIZER_WINDOWS_ARM64 1
265+
# define SANITIZER_WINDOWS_x64 0
266+
#else
267+
# define SANITIZER_WINDOWS_ARM64 0
268+
# define SANITIZER_WINDOWS_x64 1
269+
#endif
270+
263271
#if SANITIZER_SOLARIS && SANITIZER_WORDSIZE == 32
264272
# define SANITIZER_SOLARIS32 1
265273
#else

0 commit comments

Comments
 (0)