Skip to content

Commit 5f40570

Browse files
authored
[win/asan] GetInstructionSize: Support some more 5 byte instructions. (#123844)
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 23fd8f6 commit 5f40570

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
@@ -606,6 +606,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
606606

607607
case 0xb8: // b8 XX XX XX XX : mov eax, XX XX XX XX
608608
case 0xB9: // b9 XX XX XX XX : mov ecx, XX XX XX XX
609+
case 0xBA: // ba XX XX XX XX : mov edx, XX XX XX XX
609610
return 5;
610611

611612
// Cannot overwrite control-instruction. Return 0 to indicate failure.
@@ -831,6 +832,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
831832
case 0xf88349: // 49 83 f8 XX : cmp r8, XX
832833
return 4;
833834

835+
case 0x441F0F: // 0F 1F 44 XX XX : nop DWORD PTR [...]
834836
case 0x246483: // 83 64 24 XX YY : and DWORD PTR [rsp+XX], YY
835837
return 5;
836838

@@ -902,6 +904,11 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
902904
return 6;
903905
}
904906

907+
switch (0xFFFFFFFFFFULL & *(u64 *)(address)) {
908+
case 0xC07E0F4866: // 66 48 0F 7E C0 : movq rax, xmm0
909+
return 5;
910+
}
911+
905912
#else
906913

907914
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
@@ -867,6 +867,7 @@ const struct InstructionSizeData {
867867
{ 5, {0x68, 0x71, 0x72, 0x73, 0x74}, 0, "68 XX XX XX XX : push imm32"},
868868
{ 5, {0xb8, 0x71, 0x72, 0x73, 0x74}, 0, "b8 XX XX XX XX : mov eax, XX XX XX XX"},
869869
{ 5, {0xB9, 0x71, 0x72, 0x73, 0x74}, 0, "b9 XX XX XX XX : mov ecx, XX XX XX XX"},
870+
{ 5, {0xBA, 0x71, 0x72, 0x73, 0x74}, 0, "ba XX XX XX XX : mov edx, XX XX XX XX"},
870871
{ 7, {0x8D, 0xA4, 0x24, 0x73, 0x74, 0x75, 0x76}, 0, "8D A4 24 XX XX XX XX : lea esp, [esp + XX XX XX XX]"},
871872
#if SANITIZER_WINDOWS_x64
872873
// sorted list
@@ -973,6 +974,7 @@ const struct InstructionSizeData {
973974
{ 4, {0x80, 0x7D, 0x72, 0x73}, 0, "80 7D YY XX : cmp BYTE PTR [rbp+YY], XX"},
974975
{ 4, {0x80, 0x7E, 0x72, 0x73}, 0, "80 7E YY XX : cmp BYTE PTR [rsi+YY], XX"},
975976
{ 4, {0x89, 0x54, 0x24, 0x73}, 0, "89 54 24 XX : mov DWORD PTR[rsp + XX], edx"},
977+
{ 5, {0x0F, 0x1F, 0x44, 0x73, 0x74}, 0, "0F 1F 44 XX XX : nop DWORD PTR [...]"},
976978
{ 5, {0x44, 0x89, 0x44, 0x24, 0x74}, 0, "44 89 44 24 XX : mov DWORD PTR [rsp + XX], r8d"},
977979
{ 5, {0x44, 0x89, 0x4c, 0x24, 0x74}, 0, "44 89 4c 24 XX : mov DWORD PTR [rsp + XX], r9d"},
978980
{ 5, {0x48, 0x89, 0x4C, 0x24, 0x74}, 0, "48 89 4C 24 XX : mov QWORD PTR [rsp + XX], rcx"},
@@ -985,6 +987,7 @@ const struct InstructionSizeData {
985987
{ 5, {0x48, 0x8d, 0x6c, 0x24, 0x74}, 0, "48 8d 6c 24 XX : lea rbp, [rsp + XX]"},
986988
{ 5, {0x4c, 0x89, 0x44, 0x24, 0x74}, 0, "4c 89 44 24 XX : mov QWORD PTR [rsp + XX], r8"},
987989
{ 5, {0x4c, 0x89, 0x4c, 0x24, 0x74}, 0, "4c 89 4c 24 XX : mov QWORD PTR [rsp + XX], r9"},
990+
{ 5, {0x66, 0x48, 0x0F, 0x7E, 0xC0}, 0, "66 48 0F 7E C0 : movq rax, xmm0"},
988991
{ 5, {0x83, 0x44, 0x72, 0x73, 0x74}, 0, "83 44 72 XX YY : add DWORD PTR [rdx+rsi*2+XX],YY"},
989992
{ 5, {0x83, 0x64, 0x24, 0x73, 0x74}, 0, "83 64 24 XX YY : and DWORD PTR [rsp+XX], YY"},
990993
{ 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)