From 4e0706cbdff434fd4153dca3738d30272e0f4594 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Wed, 13 Nov 2019 18:21:06 +0000 Subject: [PATCH] ssp: further refine the conditional used for constructor priority __has_attribute(__constructor__) is a better test for clang than defined(__clang__). Switch to it instead. While we're already here and touching it, pfg@ nailed down when GCC actually introduced the priority argument -- 4.3. Use that instead of our hammer-guess of GCC >= 5 for the sake of correctness. --- lib/libc/secure/stack_protector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/secure/stack_protector.c b/lib/libc/secure/stack_protector.c index f60df5fbf44..63c02cd9603 100644 --- a/lib/libc/secure/stack_protector.c +++ b/lib/libc/secure/stack_protector.c @@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$"); * * This conditional should be removed when GCC 4.2 is removed. */ -#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4) +#if __has_attribute(__constructor__) || __GNUC_PREREQ__(4, 3) #define _GUARD_SETUP_CTOR_ATTR \ __attribute__((__constructor__ (200), __used__)); #else