Skip to content

Commit dc01b3a

Browse files
committed
[win/asan] GetInstructionSize: Support some more 10 or more 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. Fixes: #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 f0cc2d6 commit dc01b3a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

compiler-rt/lib/interception/interception_win.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
740740
case 0x7B81: // 81 7B YY XX XX XX XX cmp DWORD PTR [rbx+YY], XX XX XX XX
741741
case 0x7981: // 81 79 YY XX XX XX XX cmp dword ptr [rcx+YY], XX XX XX XX
742742
return 7;
743+
case 0xb848: // 48 b8 XX XX XX XX XX XX XX XX : movabs rax, XX XX XX XX XX XX XX XX
744+
return 10;
743745
}
744746

745747
switch (0x00FFFFFF & *(u32 *)address) {
@@ -915,6 +917,18 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
915917
return 5;
916918
}
917919

920+
// switch (0xFFFFFFFFFFFFULL & *(u64*)(address)) {
921+
// case 0x841f0f2e6666: // 66 66 2e 0f 1f 84 YY XX XX XX XX
922+
// // data16 cs nop WORD PTR [rax+rax*1 + XX XX XX XX]
923+
// return 11;
924+
// }
925+
//
926+
// switch (*(u64*)(address)) {
927+
// case 0x841f0f2e66666666: // 66 66 66 66 2e 0f 1f 84 YY XX XX XX XX
928+
// // data16 data16 data16 cs nop WORD PTR [rax+rax*1 + XX XX XX XX]
929+
// return 13;
930+
// }
931+
918932
#else
919933

920934
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
@@ -1067,6 +1067,9 @@ const struct InstructionSizeData {
10671067
{ 8, {0xc7, 0x44, 0x24, 0x73, 0x74, 0x75, 0x76, 0x77}, 0, "C7 44 24 XX YY YY YY YY : mov dword ptr [rsp + XX], YYYYYYYY"},
10681068
{ 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"},
10691069
{ 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]"},
1070+
{10, {0x48, 0xb8, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79}, 0, "48 b8 XX XX XX XX XX XX XX XX : movabs rax,XX XX XX XX XX XX XX XX"},
1071+
// {11, {0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x76, 0x77, 0x78, 0x79, 0x70}, 0, "66 66 2e 0f 1f 84 YY XX XX XX XX : data16 cs nop WORD PTR [rax+rax*1 + XX XX XX XX]"},
1072+
// {13, {0x66, 0x66, 0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x78, 0x79, 0x70, 0x71, 0x72}, 0, "66 66 66 66 2e 0f 1f 84 YY XX XX XX XX : data16 data16 data16 cs nop WORD PTR [rax+rax*1 + XX XX XX XX]"},
10701073
#else
10711074
// sorted list
10721075
{ 3, {0x8B, 0x45, 0x72}, 0, "8B 45 XX : mov eax, dword ptr [ebp + XX]"},

0 commit comments

Comments
 (0)