-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[win/asan] GetInstructionSize: Detect 66 90 two-byte NOP at 32-bit too.
#132267
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…too. Observed in Wine when trying to intercept `ExitThread`, which forwards to `ntdll.RtlExitUserThread`. `gdb` interprets it as `xchg %ax,%ax`. `llvm-mc` outputs simply `nop`.
Member
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: None (bernhardu) ChangesObserved in Wine when trying to intercept
CC: @zmodem 2 Files Affected:
diff --git a/compiler-rt/lib/interception/interception_win.cpp b/compiler-rt/lib/interception/interception_win.cpp
index 002b37468a200..b2974cf1934fb 100644
--- a/compiler-rt/lib/interception/interception_win.cpp
+++ b/compiler-rt/lib/interception/interception_win.cpp
@@ -646,6 +646,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
case 0xC033: // 33 C0 : xor eax, eax
case 0xC933: // 33 C9 : xor ecx, ecx
case 0xD233: // 33 D2 : xor edx, edx
+ case 0x9066: // 66 90 : xchg %ax,%ax (Two-byte NOP)
case 0xDB84: // 84 DB : test bl,bl
case 0xC084: // 84 C0 : test al,al
case 0xC984: // 84 C9 : test cl,cl
@@ -726,7 +727,6 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
case 0x5541: // push r13
case 0x5641: // push r14
case 0x5741: // push r15
- case 0x9066: // Two-byte NOP
case 0xc084: // test al, al
case 0x018a: // mov al, byte ptr [rcx]
return 2;
diff --git a/compiler-rt/lib/interception/tests/interception_win_test.cpp b/compiler-rt/lib/interception/tests/interception_win_test.cpp
index 2a7549d230ae2..893f346d73b8a 100644
--- a/compiler-rt/lib/interception/tests/interception_win_test.cpp
+++ b/compiler-rt/lib/interception/tests/interception_win_test.cpp
@@ -845,6 +845,7 @@ const struct InstructionSizeData {
{ 2, {0x33, 0xC0}, 0, "33 C0 : xor eax, eax"},
{ 2, {0x33, 0xC9}, 0, "33 C9 : xor ecx, ecx"},
{ 2, {0x33, 0xD2}, 0, "33 D2 : xor edx, edx"},
+ { 2, {0x66, 0x90}, 0, "66 90 : xchg %ax,%ax (Two-byte NOP)"},
{ 2, {0x6A, 0x71}, 0, "6A XX : push XX"},
{ 2, {0x84, 0xC0}, 0, "84 C0 : test al,al"},
{ 2, {0x84, 0xC9}, 0, "84 C9 : test cl,cl"},
@@ -887,7 +888,6 @@ const struct InstructionSizeData {
{ 2, {0x41, 0x55}, 0, "41 55 : push r13"},
{ 2, {0x41, 0x56}, 0, "41 56 : push r14"},
{ 2, {0x41, 0x57}, 0, "41 57 : push r15"},
- { 2, {0x66, 0x90}, 0, "66 90 : Two-byte NOP"},
{ 2, {0x84, 0xc0}, 0, "84 c0 : test al, al"},
{ 2, {0x8a, 0x01}, 0, "8a 01 : mov al, byte ptr [rcx]"},
{ 3, {0x0f, 0xb6, 0x01}, 0, "0f b6 01 : movzx eax, BYTE PTR [rcx]"},
|
zmodem
approved these changes
Mar 21, 2025
Collaborator
zmodem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Observed in Wine when trying to intercept
ExitThread, which forwards tontdll.RtlExitUserThread.gdbinterprets it asxchg %ax,%ax.llvm-mcoutputs simplynop.CC: @zmodem