diff options
| author | Kyle Evans <kevans@FreeBSD.org> | 2019-11-13 02:14:17 +0000 |
|---|---|---|
| committer | Kyle Evans <kevans@FreeBSD.org> | 2019-11-13 02:14:17 +0000 |
| commit | d0fa84f4743132cdc046965252f655b352aa0095 (patch) | |
| tree | ff1dfa2e0287f93b41abedebb7c518376e8a86d1 /lib/libc/secure | |
| parent | 02fa548cde3215113a7004f60bf8597a8a7d50cd (diff) | |
Notes
Diffstat (limited to 'lib/libc/secure')
| -rw-r--r-- | lib/libc/secure/stack_protector.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/libc/secure/stack_protector.c b/lib/libc/secure/stack_protector.c index 34bb7d0332a3..e7e053a36450 100644 --- a/lib/libc/secure/stack_protector.c +++ b/lib/libc/secure/stack_protector.c @@ -40,11 +40,27 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include "libc_private.h" +/* + * We give __guard_setup a defined priority early on so that statically linked + * applications have a defined priority at which __stack_chk_guard will be + * getting initialized. This will not matter to most applications, because + * 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. + */ +#if defined(__GNUC__) && __GNUC__ <= 4 +#define _GUARD_SETUP_CTOR_ATTR \ + __attribute__((__constructor__, __used__)); +#else +#define _GUARD_SETUP_CTOR_ATTR \ + __attribute__((__constructor__ (200), __used__)); +#endif + extern int __sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen); long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0}; -static void __guard_setup(void) __attribute__((__constructor__, __used__)); +static void __guard_setup(void) _GUARD_SETUP_CTOR_ATTR; static void __fail(const char *); void __stack_chk_fail(void); void __chk_fail(void); |
