Skip to content

Commit 4a7bffe

Browse files
committed
[win/asan] GetInstructionSize: Support some more 5 byte instructions.
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 d00d000 commit 4a7bffe

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

compiler-rt/lib/interception/interception_win.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
594594

595595
case 0xb8: // b8 XX XX XX XX : mov eax, XX XX XX XX
596596
case 0xB9: // b9 XX XX XX XX : mov ecx, XX XX XX XX
597+
case 0xBA: // ba XX XX XX XX : mov edx, XX XX XX XX
597598
return 5;
598599

599600
// Cannot overwrite control-instruction. Return 0 to indicate failure.
@@ -900,6 +901,12 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
900901
return 6;
901902
}
902903

904+
switch (0xFFFFFFFFFFULL & *(u64*)(address)) {
905+
case 0xC07E0F4866: // 66 48 0F 7E C0 : movq rax,xmm0 (for wine fexp)
906+
case 0x0000441F0F: // 0F 1F 44 00 00 : nop DWORD PTR [rax+rax*1+0x0]
907+
return 5;
908+
}
909+
903910
#else
904911

905912
switch (*(u8*)address) {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ const struct InstructionSizeData {
893893
{ 5, {0x68, 0x71, 0x72, 0x73, 0x74}, 0, "68 XX XX XX XX : push imm32"},
894894
{ 5, {0xb8, 0x71, 0x72, 0x73, 0x74}, 0, "b8 XX XX XX XX : mov eax, XX XX XX XX"},
895895
{ 5, {0xB9, 0x71, 0x72, 0x73, 0x74}, 0, "b9 XX XX XX XX : mov ecx, XX XX XX XX"},
896+
{ 5, {0xBA, 0x71, 0x72, 0x73, 0x74}, 0, "ba XX XX XX XX : mov edx, XX XX XX XX"},
896897
{ 7, {0x8D, 0xA4, 0x24, 0x73, 0x74, 0x75, 0x76}, 0, "8D A4 24 XX XX XX XX : lea esp, [esp + XX XX XX XX]"},
897898
#if SANITIZER_WINDOWS_x64
898899
// sorted list
@@ -1007,6 +1008,7 @@ const struct InstructionSizeData {
10071008
{ 4, {0x80, 0x7D, 0x72, 0x73}, 0, "80 7D YY XX : cmp BYTE PTR [rbp+YY], XX"},
10081009
{ 4, {0x80, 0x7E, 0x72, 0x73}, 0, "80 7E YY XX : cmp BYTE PTR [rsi+YY], XX"},
10091010
{ 4, {0x89, 0x54, 0x24, 0x73}, 0, "89 54 24 XX : mov DWORD PTR[rsp + XX], edx"},
1011+
{ 5, {0x0F, 0x1F, 0x44, 0x00, 0x00}, 0, "0F 1F 44 00 00 : nop DWORD PTR [rax+rax*1+0x0]"},
10101012
{ 5, {0x44, 0x89, 0x44, 0x24, 0x74}, 0, "44 89 44 24 XX : mov DWORD PTR [rsp + XX], r8d"},
10111013
{ 5, {0x44, 0x89, 0x4c, 0x24, 0x74}, 0, "44 89 4c 24 XX : mov DWORD PTR [rsp + XX], r9d"},
10121014
{ 5, {0x48, 0x89, 0x4C, 0x24, 0x74}, 0, "48 89 4C 24 XX : mov QWORD PTR [rsp + XX], rcx"},
@@ -1019,6 +1021,7 @@ const struct InstructionSizeData {
10191021
{ 5, {0x48, 0x8d, 0x6c, 0x24, 0x74}, 0, "48 8d 6c 24 XX : lea rbp, [rsp + XX]"},
10201022
{ 5, {0x4c, 0x89, 0x44, 0x24, 0x74}, 0, "4c 89 44 24 XX : mov QWORD PTR [rsp + XX], r8"},
10211023
{ 5, {0x4c, 0x89, 0x4c, 0x24, 0x74}, 0, "4c 89 4c 24 XX : mov QWORD PTR [rsp + XX], r9"},
1024+
{ 5, {0x66, 0x48, 0x0F, 0x7E, 0xC0}, 0, "66 48 0F 7E C0 : movq rax,xmm0 (for wine fexp)"},
10221025
{ 5, {0x83, 0x44, 0x72, 0x73, 0x74}, 0, "83 44 72 XX YY : add DWORD PTR [rdx+rsi*2+XX],YY"},
10231026
{ 5, {0x83, 0x64, 0x24, 0x73, 0x74}, 0, "83 64 24 XX YY : and DWORD PTR [rsp+XX], YY"},
10241027
{ 6, {0x48, 0x83, 0x64, 0x24, 0x74, 0x75}, 0, "48 83 64 24 XX YY : and QWORD PTR [rsp + XX], YY"},

0 commit comments

Comments
 (0)