Hot to test for _FORTIFY_SOURCE with Autoconf
Jim Wilson
jimw@sifive.com
Wed Mar 18 22:17:27 GMT 2020
On Tue, Mar 17, 2020 at 5:16 PM Jeffrey Walton via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
> When _FORTIFY_SOURCE=2 is used, *_chk functions are used when the
> compiler can determine the destination buffer size. Effectively the
> compiler inserts those Microsoft safer functions that the libc folks
> rejected.
Then that is how you test for it in a configure script. Just write a
trivial program that will generate a call to a *_chk function if
_FORTIFY_SOURCE=2 is supported, compile it, and then check for that,
either by greping the assembly source or running nm on the object
file.
Jim
More information about the Gcc-help
mailing list