I need to suppress Buffer Security Check (/GS) feature (MSVC) for some functions but not for entire Project as /GS- doing. MSVSC documentation https://docs.microsoft.com/en-us/cpp/preprocessor/strict-gs-check?view=vs-2017 prompts to use #pragma strict_gs_check(off). Unfortunately, it doesn't work for me - I still see the "cookies" in the assembly. Any help, please.
This is simplest code to reproduce, godbold link here: https://godbolt.org/z/gYiGam
#include <memory>
struct Tmp {
char v[8];
};
//#pragma check_stack(off)
#pragma strict_gs_check(off)
int make1(Tmp& a)
{
Tmp r;
return memcmp(&r, &a, sizeof(r));
}
//result
//-------------------------
pop esi
mov ecx, DWORD PTR __$ArrayPad$[esp+12]
xor ecx, esp
call @__security_check_cookie@4
add esp, 12 ; 0000000cH
ret 0
$LN6@make1:
mov ecx, DWORD PTR __$ArrayPad$[esp+16]
sbb eax, eax
pop esi
xor ecx, esp
or eax, 1
call @__security_check_cookie@4
add esp, 12 ; 0000000cH
ret 0
int make1(Tmp &) ENDP ; make1