From 5ba134a46440f6d491262e43fe4aedda75ab017e Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Wed, 13 Nov 2019 03:00:32 +0000 Subject: [PATCH] ssp: rework the logic to use priority=200 on clang builds The preproc logic was added at the last minute to appease GCC 4.2, and kevans@ did clearly not go back and double-check that the logic worked out for clang builds to use the new variant. It turns out that clang defines __GNUC__ == 4. Flip it around and check __clang__ as well, leaving a note to remove it later. Reported by: cem --- lib/libc/secure/stack_protector.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/libc/secure/stack_protector.c b/lib/libc/secure/stack_protector.c index e7e053a3645..f60df5fbf44 100644 --- a/lib/libc/secure/stack_protector.c +++ b/lib/libc/secure/stack_protector.c @@ -47,13 +47,15 @@ __FBSDID("$FreeBSD$"); * they're either not usually statically linked or they simply don't do things * in constructors that would be adversely affected by their positioning with * respect to this initialization. + * + * This conditional should be removed when GCC 4.2 is removed. */ -#if defined(__GNUC__) && __GNUC__ <= 4 -#define _GUARD_SETUP_CTOR_ATTR \ - __attribute__((__constructor__, __used__)); -#else +#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4) #define _GUARD_SETUP_CTOR_ATTR \ __attribute__((__constructor__ (200), __used__)); +#else +#define _GUARD_SETUP_CTOR_ATTR \ + __attribute__((__constructor__, __used__)); #endif extern int __sysctl(const int *name, u_int namelen, void *oldp,