Skip to content

Commit f85579f

Browse files
authored
[win/asan] GetInstructionSize: Fix 83 E4 XX to return 3. (#119644)
This consolidates the two different lines for x86 and x86_64 into a single line for both architectures. And adds a test line. CC: @zmodem
1 parent 8182568 commit f85579f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler-rt/lib/interception/interception_win.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
634634
case 0xD284: // 84 D2 : test dl,dl
635635
return 2;
636636

637+
case 0xE483: // 83 E4 XX : and esp, XX
637638
case 0xEC83: // 83 EC XX : sub esp, XX
638639
case 0xC1F6: // F6 C1 XX : test cl, XX
639640
return 3;
@@ -643,8 +644,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
643644
return 0;
644645
}
645646

646-
switch (0x00FFFFFF & *(u32*)address) {
647-
case 0xF8E483: // 83 E4 F8 : and esp, 0xFFFFFFF8
647+
switch (0x00FFFFFF & *(u32 *)address) {
648648
case 0x24A48D: // 8D A4 24 XX XX XX XX : lea esp, [esp + XX XX XX XX]
649649
return 7;
650650
}
@@ -773,7 +773,6 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
773773
case 0xdb8548: // 48 85 db : test rbx, rbx
774774
case 0xdb854d: // 4d 85 db : test r11, r11
775775
case 0xdc8b4c: // 4c 8b dc : mov r11, rsp
776-
case 0xe0e483: // 83 e4 e0 : and esp, 0xFFFFFFE0
777776
case 0xe48548: // 48 85 e4 : test rsp, rsp
778777
case 0xe4854d: // 4d 85 e4 : test r12, r12
779778
case 0xe58948: // 48 89 e5 : mov rbp, rsp

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ const struct InstructionSizeData {
852852
{ 2, {0x8B, 0xC1}, 0, "8B C1 : mov eax, ecx"},
853853
{ 2, {0x8B, 0xEC}, 0, "8B EC : mov ebp, esp"},
854854
{ 2, {0x8B, 0xFF}, 0, "8B FF : mov edi, edi"},
855+
{ 3, {0x83, 0xE4, 0x72}, 0, "83 E4 XX : and esp, XX"},
855856
{ 3, {0x83, 0xEC, 0x72}, 0, "83 EC XX : sub esp, XX"},
856857
{ 3, {0xc2, 0x71, 0x72}, 0, "C2 XX XX : ret XX (needed for registering weak functions)"},
857858
{ 5, {0x68, 0x71, 0x72, 0x73, 0x74}, 0, "68 XX XX XX XX : push imm32"},

0 commit comments

Comments
 (0)