Skip to content

[win/asan] GetInstructionSize: Support 48 bX movabsq instructions. #141625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2025

Conversation

bernhardu
Copy link
Contributor

Created for Wine's memset by clang or mingw-gcc,
the latter places it quite at the start of the function:

   0x00006ffffb67e210 <memset+0>:       0f b6 d2                movzbl %dl,%edx
   0x00006ffffb67e213 <memset+3>:       48 b8 01 01 01 01 01 01 01 01   movabs $0x101010101010101,%rax

3200 uint64_t v = 0x101010101010101ull * (unsigned char)c;

https://gitlab.winehq.org/wine/wine/-/blob/290fd532ee7376442d272e3833528256bfe5e9dc/dlls/msvcrt/string.c#L3200

Created for Wine's memset by clang or mingw-gcc,
the latter places it quite at the start of the function:

```
   0x00006ffffb67e210 <memset+0>:       0f b6 d2                movzbl %dl,%edx
   0x00006ffffb67e213 <memset+3>:       48 b8 01 01 01 01 01 01 01 01   movabs $0x101010101010101,%rax
```

`3200      uint64_t v = 0x101010101010101ull * (unsigned char)c;`

https://gitlab.winehq.org/wine/wine/-/blob/290fd532ee7376442d272e3833528256bfe5e9dc/dlls/msvcrt/string.c#L3200
@bernhardu
Copy link
Contributor Author

CC: @zmodem

@llvmbot
Copy link
Member

llvmbot commented May 27, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: None (bernhardu)

Changes

Created for Wine's memset by clang or mingw-gcc,
the latter places it quite at the start of the function:

   0x00006ffffb67e210 &lt;memset+0&gt;:       0f b6 d2                movzbl %dl,%edx
   0x00006ffffb67e213 &lt;memset+3&gt;:       48 b8 01 01 01 01 01 01 01 01   movabs $0x101010101010101,%rax

3200 uint64_t v = 0x101010101010101ull * (unsigned char)c;

https://gitlab.winehq.org/wine/wine/-/blob/290fd532ee7376442d272e3833528256bfe5e9dc/dlls/msvcrt/string.c#L3200


Full diff: https://github.com/llvm/llvm-project/pull/141625.diff

2 Files Affected:

  • (modified) compiler-rt/lib/interception/interception_win.cpp (+6)
  • (modified) compiler-rt/lib/interception/tests/interception_win_test.cpp (+2)
diff --git a/compiler-rt/lib/interception/interception_win.cpp b/compiler-rt/lib/interception/interception_win.cpp
index c9a77180014c4..246a22c56c31a 100644
--- a/compiler-rt/lib/interception/interception_win.cpp
+++ b/compiler-rt/lib/interception/interception_win.cpp
@@ -754,6 +754,12 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
     case 0x7B81:  // 81 7B YY XX XX XX XX  cmp DWORD PTR [rbx+YY], XX XX XX XX
     case 0x7981:  // 81 79 YY XX XX XX XX  cmp dword ptr [rcx+YY], XX XX XX XX
       return 7;
+
+    case 0xb848:  // 48 b8 XX XX XX XX XX XX XX XX :
+                  //   movabsq XX XX XX XX XX XX XX XX, rax
+    case 0xba48:  // 48 ba XX XX XX XX XX XX XX XX :
+                  //   movabsq XX XX XX XX XX XX XX XX, rdx
+      return 10;
   }
 
   switch (0x00FFFFFF & *(u32 *)address) {
diff --git a/compiler-rt/lib/interception/tests/interception_win_test.cpp b/compiler-rt/lib/interception/tests/interception_win_test.cpp
index 893f346d73b8a..f11c1d1458556 100644
--- a/compiler-rt/lib/interception/tests/interception_win_test.cpp
+++ b/compiler-rt/lib/interception/tests/interception_win_test.cpp
@@ -1043,6 +1043,8 @@ const struct InstructionSizeData {
     { 8, {0xc7, 0x44, 0x24, 0x73, 0x74, 0x75, 0x76, 0x77}, 0, "C7 44 24 XX YY YY YY YY : mov dword ptr [rsp + XX], YYYYYYYY"},
     { 9, {0x41, 0x81, 0x7c, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78}, 0, "41 81 7c ZZ YY XX XX XX XX : cmp DWORD PTR [reg+reg*n+YY], XX XX XX XX"},
     { 9, {0xA1, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78}, 0, "A1 XX XX XX XX XX XX XX XX : movabs eax, dword ptr ds:[XXXXXXXX]"},
+    {10, {0x48, 0xb8, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79}, 0, "48 b8 XX XX XX XX XX XX XX XX : movabsq XX XX XX XX XX XX XX XX, rax"},
+    {10, {0x48, 0xba, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79}, 0, "48 ba XX XX XX XX XX XX XX XX : movabsq XX XX XX XX XX XX XX XX, rdx"},
 #else
     // sorted list
     { 3, {0x8B, 0x45, 0x72}, 0, "8B 45 XX : mov eax, dword ptr [ebp + XX]"},

Copy link
Collaborator

@zmodem zmodem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Do you need me to press the merge button?

@bernhardu
Copy link
Contributor Author

lgtm

Do you need me to press the merge button?

Thanks for having a look, yes, if you could press the button would be great.

@zmodem zmodem merged commit 3297340 into llvm:main Jun 2, 2025
13 checks passed
@bernhardu bernhardu deleted the mr-interception_win-add-movabsq branch June 2, 2025 07:09
DhruvSrivastavaX pushed a commit to DhruvSrivastavaX/lldb-for-aix that referenced this pull request Jun 12, 2025
…lvm#141625)

Created for Wine's memset by clang or mingw-gcc,
the latter places it quite at the start of the function:

```
   0x00006ffffb67e210 <memset+0>:       0f b6 d2                movzbl %dl,%edx
   0x00006ffffb67e213 <memset+3>:       48 b8 01 01 01 01 01 01 01 01   movabs $0x101010101010101,%rax
```

`3200      uint64_t v = 0x101010101010101ull * (unsigned char)c;`


https://gitlab.winehq.org/wine/wine/-/blob/290fd532ee7376442d272e3833528256bfe5e9dc/dlls/msvcrt/string.c#L3200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants