Is it possible to use -Wp,-D_FORTIFY_SOURCE=2 option (or =1) along with -Og optimization level? The patch which introduces FORTIFY_SOURCE contains a comment /* Object size checking is only intended for -O[s123]. */.
It is 2004 year. And I don't know when -Og key is introduced (maybe later).
Which optimizations (optimization flags) FORTIFY_SOURCE requires namely?
Fortification requires __OPTIMIZE__ macro greater than 0:
$ cat /usr/include/features
#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
&& __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
# if _FORTIFY_SOURCE > 1
# define __USE_FORTIFY_LEVEL 2
-Og is no different from other -O flags in defining __OPTIMIZE__:
$ gcc -E -Og -dM -x c /dev/null 2>&1 | grep OPTIMIZE
#define __OPTIMIZE__ 1
so you should be fine.
You can ask Glibc developers to update the comment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With