I'm trying to find information on what is required for implementing fortified functions in GCC for libc.
From what I understand the __builtin__*_chk variants are for compile-time checks but if GCC can't determine buffer sizes he will replace the call with the __*_chk version if they exist.
Is the above assertion correct? If so where can I find documentation on what is required by GCC in libc to tie together a function to it's runtime __*_chk version when FORTIFY_SOURCE=1|2?
Thanks
Fortification is mostly implemented in Glibc via GCC's
__builtin_constant_pand__builtin_object_sizeintrinsics. E.g. here's definition ofmemsetfrom/usr/include/string.h:__builtin___memset_chkis simply expanded by GCC to a call tomemset_chk(also defined in libc.so).GCC knows about
*_chkfunctions but only uses this knowledge to perform optimizations (dead code removal, folding, etc.), not for verification.