From 414e0baa0ef0ab577775f532d4436ee75be17d73 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Wed, 29 May 2019 21:53:04 +0100 Subject: [PATCH] Add Control Flow Guard checks on Windows. --- objc_msgSend.x86-32.S | 13 +++++++++++-- objc_msgSend.x86-64.S | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/objc_msgSend.x86-32.S b/objc_msgSend.x86-32.S index 3c3b113..530c9df 100644 --- a/objc_msgSend.x86-32.S +++ b/objc_msgSend.x86-32.S @@ -36,8 +36,11 @@ test %eax, %eax jz 5f # Nil slot - invoke some kind of forwarding mechanism - mov SLOT_OFFSET(%eax), %eax - jmp *%eax + mov SLOT_OFFSET(%eax), %ecx +#ifdef _WIN32 + call *CDECL(__guard_check_icall_fptr) +#endif + jmp *%ecx 4: # returnNil: .if \fpret fldz @@ -58,7 +61,13 @@ add $8, %esp # restore the stack +#ifdef _WIN32 + mov %eax, %ecx + call *CDECL(__guard_check_icall_fptr) + jmp *%ecx +#else jmp *%eax +#endif 6: # smallObject: push %ebx # Save old %ebx calll 7f diff --git a/objc_msgSend.x86-64.S b/objc_msgSend.x86-64.S index cffb42b..ab64836 100644 --- a/objc_msgSend.x86-64.S +++ b/objc_msgSend.x86-64.S @@ -193,7 +193,12 @@ 12: #endif // WITH_TRACING +#ifdef _WIN64 + mov %r10, %rax + jmp *__guard_dispatch_icall_fptr(%rip) +#else jmp *%r10 +#endif 4: # returnNil: # Both of the return registers are # callee-save on x86-64, so we can