c++cvisual-c++

Gen code without runtime checks in VC++


How do I generate pure code (without runtime checks) in VC++ 2010 Express ? For example I removed Buffer Security Check ( set compile opt /GS-), but in my code I again saw these calls

call __security_init_cookie
...
call _RTC_CheckEsp
...
call _RTC_CheckEsp
...

How do I remove these calls?


Solution

  • The MSVC docs indicate that __security_init_cookie is called by the CRT runtime for "code compiled with /GS (Buffer Security Check) and in code that uses exception handling" (emphasis added). See http://msdn.microsoft.com/en-us/library/ms235362%28v=VS.100%29.aspx

    I wouldn't be surprised if there's code in the runtime library itself that depends on the security cookie having been initialized, whether your code uses it or not (in other words, the runtime library code may have been compiled with /GS, and if so, it needs the cookie initialized whether or not your code does).

    As for the _RTC_CheckEsp call - that should be controlled by the /RTCs or the /RTC1 option. Remove those options from your build and there should be no calls to _RTC_CheckEsp.