This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] BZ #13979- A warning should be issued if FORTIFY_SOURCEis requested but not enabled


On 05/07/2012 11:15 PM, Roland McGrath wrote:
	* include/features.h: Warn if user requests FORTIFY_SOURCE checking
	but the checks are disabled for any reason.

Use the correct name in the log: _FORTIFY_SOURCE.


+#if defined _FORTIFY_SOURCE&&  _FORTIFY_SOURCE>  0&&  __USE_FORTIFY_LEVEL == 0
+# warning _FORTIFY_SOURCE requested but disabled
+#endif

It's probably more helpful to say something specific:


# if !defined __OPTIMIZE__ || __OPTIMIZE__<= 0
#  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
# elif !__GNUC_PREREQ (4, 1)
#  warning _FORTIFY_SOURCE is only supported with GCC 4.1 or later
# else
#  warning _FORTIFY_SOURCE is not available for mysterious reasons
# endif

It also seems cleaner to move this into the #if nest that actually sets
__USE_FORTIFY_LEVEL, perhaps reorganizing that a little as needed.

Good idea.


Here's what I'm testing now:

#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
    && __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
# if _FORTIFY_SOURCE > 1
#  define __USE_FORTIFY_LEVEL 2
# else
#  define __USE_FORTIFY_LEVEL 1
# endif
#else
# define __USE_FORTIFY_LEVEL 0
# if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0
#  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
# elif !__GNUC_PREREQ (4, 1)
#  warning _FORTIFY_SOURCE is only supported with GCC 4.1 or later
# endif
#endif


Andreas -- Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg) GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]