Skip to content

Commit 56592a8

Browse files
authored
[win/asan] GetInstructionSize: Support some more 4 byte instructions. (#123709)
This patch adds several instructions seen when trying to run a executable built with ASan with llvm-mingw. (x86 and x86_64, using the git tip in llvm-project). Also includes instructions collected by Roman Pišl and Eric Pouech in the Wine bug reports below. ``` Related: #96270 Co-authored-by: Roman Pišl <[email protected]> https://bugs.winehq.org/show_bug.cgi?id=50993 https://bugs.winehq.org/attachment.cgi?id=70233 Co-authored-by: Eric Pouech <[email protected]> https://bugs.winehq.org/show_bug.cgi?id=52386 https://bugs.winehq.org/attachment.cgi?id=71626 ```
1 parent 0d24130 commit 56592a8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

compiler-rt/lib/interception/interception_win.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,9 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
667667
}
668668

669669
switch (0x00FFFFFF & *(u32 *)address) {
670+
case 0x244C8D: // 8D 4C 24 XX : lea ecx, [esp + XX]
671+
case 0x2474FF: // FF 74 24 XX : push qword ptr [rsp + XX]
672+
return 4;
670673
case 0x24A48D: // 8D A4 24 XX XX XX XX : lea esp, [esp + XX XX XX XX]
671674
return 7;
672675
}
@@ -830,6 +833,10 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
830833
case 0x588948: // 48 89 58 XX : mov QWORD PTR[rax + XX], rbx
831834
case 0xec8348: // 48 83 ec XX : sub rsp, XX
832835
case 0xf88349: // 49 83 f8 XX : cmp r8, XX
836+
case 0x488d49: // 49 8d 48 XX : lea rcx, [...]
837+
case 0x048d4c: // 4c 8d 04 XX : lea r8, [...]
838+
case 0x148d4e: // 4e 8d 14 XX : lea r10, [...]
839+
case 0x398366: // 66 83 39 XX : cmp WORD PTR [rcx], XX
833840
return 4;
834841

835842
case 0x441F0F: // 0F 1F 44 XX XX : nop DWORD PTR [...]
@@ -885,6 +892,10 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
885892
}
886893

887894
switch (*(u32*)(address)) {
895+
case 0x01b60f44: // 44 0f b6 01 : movzx r8d, BYTE PTR [rcx]
896+
case 0x09b60f44: // 44 0f b6 09 : movzx r9d, BYTE PTR [rcx]
897+
case 0x0ab60f44: // 44 0f b6 0a : movzx r8d, BYTE PTR [rdx]
898+
case 0x11b60f44: // 44 0f b6 11 : movzx r10d, BYTE PTR [rcx]
888899
case 0x1ab60f44: // 44 0f b6 1a : movzx r11d, BYTE PTR [rdx]
889900
return 4;
890901
case 0x24448b48: // 48 8b 44 24 XX : mov rax, QWORD ptr [rsp + XX]

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,8 @@ const struct InstructionSizeData {
864864
{ 3, {0x8B, 0x55, 0x72}, 0, "8B 55 XX : mov XX(%ebp), edx"},
865865
{ 3, {0x8B, 0x75, 0x72}, 0, "8B 75 XX : mov XX(%ebp), esp"},
866866
{ 3, {0xc2, 0x71, 0x72}, 0, "C2 XX XX : ret XX (needed for registering weak functions)"},
867+
{ 4, {0x8D, 0x4C, 0x24, 0x73}, 0, "8D 4C 24 XX : lea ecx, [esp + XX]"},
868+
{ 4, {0xFF, 0x74, 0x24, 0x73}, 0, "FF 74 24 XX : push qword ptr [rsp + XX]"},
867869
{ 5, {0x68, 0x71, 0x72, 0x73, 0x74}, 0, "68 XX XX XX XX : push imm32"},
868870
{ 5, {0xb8, 0x71, 0x72, 0x73, 0x74}, 0, "b8 XX XX XX XX : mov eax, XX XX XX XX"},
869871
{ 5, {0xB9, 0x71, 0x72, 0x73, 0x74}, 0, "b9 XX XX XX XX : mov ecx, XX XX XX XX"},
@@ -962,11 +964,19 @@ const struct InstructionSizeData {
962964
{ 3, {0x4d, 0x85, 0xf6}, 0, "4d 85 f6 : test r14, r14"},
963965
{ 3, {0x4d, 0x85, 0xff}, 0, "4d 85 ff : test r15, r15"},
964966
{ 3, {0xf6, 0xc1, 0x72}, 0, "f6 c1 XX : test cl, XX"},
967+
{ 4, {0x44, 0x0f, 0xb6, 0x01}, 0, "44 0f b6 01 : movzx r8d, BYTE PTR [rcx]"},
968+
{ 4, {0x44, 0x0f, 0xb6, 0x09}, 0, "44 0f b6 09 : movzx r9d, BYTE PTR [rcx]"},
969+
{ 4, {0x44, 0x0f, 0xb6, 0x0a}, 0, "44 0f b6 0a : movzx r8d, BYTE PTR [rdx]"},
970+
{ 4, {0x44, 0x0f, 0xb6, 0x11}, 0, "44 0f b6 11 : movzx r10d, BYTE PTR [rcx]"},
965971
{ 4, {0x44, 0x0f, 0xb6, 0x1a}, 0, "44 0f b6 1a : movzx r11d, BYTE PTR [rdx]"},
966972
{ 4, {0x44, 0x8d, 0x42, 0x73}, 0, "44 8d 42 XX : lea r8d , [rdx + XX]"},
967973
{ 4, {0x48, 0x83, 0xec, 0x73}, 0, "48 83 ec XX : sub rsp, XX"},
968974
{ 4, {0x48, 0x89, 0x58, 0x73}, 0, "48 89 58 XX : mov QWORD PTR[rax + XX], rbx"},
969975
{ 4, {0x49, 0x83, 0xf8, 0x73}, 0, "49 83 f8 XX : cmp r8, XX"},
976+
{ 4, {0x49, 0x8d, 0x48, 0x73}, 0, "49 8d 48 XX : lea rcx, [...]"},
977+
{ 4, {0x4c, 0x8d, 0x04, 0x73}, 0, "4c 8d 04 XX : lea r8, [...]"},
978+
{ 4, {0x4e, 0x8d, 0x14, 0x73}, 0, "4e 8d 14 XX : lea r10, [...]"},
979+
{ 4, {0x66, 0x83, 0x39, 0x73}, 0, "66 83 39 XX : cmp WORD PTR [rcx], XX"},
970980
{ 4, {0x80, 0x78, 0x72, 0x73}, 0, "80 78 YY XX : cmp BYTE PTR [rax+YY], XX"},
971981
{ 4, {0x80, 0x79, 0x72, 0x73}, 0, "80 79 YY XX : cmp BYTE ptr [rcx+YY], XX"},
972982
{ 4, {0x80, 0x7A, 0x72, 0x73}, 0, "80 7A YY XX : cmp BYTE PTR [rdx+YY], XX"},

0 commit comments

Comments
 (0)