Skip to content

Commit b5b73ce

Browse files
Charlie BartoCharlie Barto
authored andcommitted
[sanitizer][asan][msvc] Teach GetInstructionSize about many instructions that appear in MSVC generated code.
MSVC can sometimes generates instructions in function prefixes that asan previously didn't know the size of, this teaches asan those sizes. This isn't hilariously useful for using ASAN with non-msvc compilers, but it does stand alone. Differential Revision: https://reviews.llvm.org/D151008
1 parent ba4c1a9 commit b5b73ce

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

compiler-rt/lib/interception/interception_win.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -564,17 +564,17 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
564564
return 9;
565565
case 0xf2:
566566
switch (*(u32 *)(address + 1)) {
567-
case 0x2444110f: // f2 0f 11 44 24 XX movsd mmword ptr [rsp + XX],
568-
// xmm0
569-
case 0x244c110f: // f2 0f 11 4c 24 XX movsd QWORD PTR
570-
// [rsp+0x8],xmm1
571-
case 0x2454110f: // f2 0f 11 54 24 XX movsd QWORD PTR
572-
// [rsp+0x8],xmm2
573-
case 0x245c110f: // f2 0f 11 5c 24 XX movsd QWORD PTR
574-
// [rsp+0x8],xmm3
575-
case 0x2464110f: // f2 0f 11 64 24 XX movsd QWORD PTR
576-
// [rsp+0x8],xmm4
577-
return 6;
567+
case 0x2444110f: // f2 0f 11 44 24 XX movsd mmword ptr [rsp +
568+
// XX], xmm0
569+
case 0x244c110f: // f2 0f 11 4c 24 XX movsd QWORD PTR
570+
// [rsp+0x8],xmm1
571+
case 0x2454110f: // f2 0f 11 54 24 XX movsd QWORD PTR
572+
// [rsp+0x8],xmm2
573+
case 0x245c110f: // f2 0f 11 5c 24 XX movsd QWORD PTR
574+
// [rsp+0x8],xmm3
575+
case 0x2464110f: // f2 0f 11 64 24 XX movsd QWORD PTR
576+
// [rsp+0x8],xmm4
577+
return 6;
578578
}
579579
break;
580580

@@ -705,15 +705,16 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
705705

706706
case 0xec8148: // 48 81 EC XX XX XX XX : sub rsp, XXXXXXXX
707707
return 7;
708-
case 0x788141: // 41 81 78 YY XX XX XX XX cmp DWORD PTR [r8+YY], XX XX XX XX
709-
case 0x798141: // r9
710-
case 0x7a8141: //r10
711-
case 0x7b8141: //r11
712-
case 0x7c8141: //r12
713-
case 0x7d8141: //r13
714-
case 0x7e8141: //r14
715-
case 0x7f8141: // 41 81 78 YY XX XX XX XX cmp DWORD P [r15+YY], XX XX XX XX
716-
case 0x247c81: // 81 7c 24 YY XX XX XX XX cmp DWORD P [rsp+YY], XX XX XX XX
708+
case 0x788141: // 41 81 78 YY XX XX XX XX cmp DWORD PTR [r8+YY], XX XX XX
709+
// XX
710+
case 0x798141: // r9
711+
case 0x7a8141: // r10
712+
case 0x7b8141: // r11
713+
case 0x7c8141: // r12
714+
case 0x7d8141: // r13
715+
case 0x7e8141: // r14
716+
case 0x7f8141: // 41 81 78 YY XX XX XX XX cmp DWORD P [r15+YY], XX XX XX XX
717+
case 0x247c81: // 81 7c 24 YY XX XX XX XX cmp DWORD P [rsp+YY], XX XX XX XX
717718
return 8;
718719

719720
case 0x058b48: // 48 8b 05 XX XX XX XX :

0 commit comments

Comments
 (0)