diff --git a/lib/libthr/thread/thr_printf.c b/lib/libthr/thread/thr_printf.c index e1edffe5acb2d4..29c96d6b801879 100644 --- a/lib/libthr/thread/thr_printf.c +++ b/lib/libthr/thread/thr_printf.c @@ -58,10 +58,18 @@ _thread_printf(int fd, const char *fmt, ...) va_end(ap); } +/* GCC has had this for a long while now, but Clang only got it + recently. */ +#if __has_attribute(__nonstring__) +# define __nonstring __attribute__((__nonstring__)) +#else +# define __nonstring +#endif + void _thread_vprintf(int fd, const char *fmt, va_list ap) { - static const char digits[16] = "0123456789abcdef"; + __nonstring static const char digits[16] = "0123456789abcdef"; char buf[20]; char *s; unsigned long r, u; diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index d27af520c21d1d..9b0c96fa80dc1d 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -343,12 +343,20 @@ static void (*rtld_exit_ptr)(void); ld_utrace_log(e, h, mb, ms, r, n); \ } while (0) +/* GCC has had this for a long while now, but Clang only got it + recently. */ +#if __has_attribute(__nonstring__) +# define __nonstring __attribute__((__nonstring__)) +#else +# define __nonstring +#endif + static void ld_utrace_log(int event, void *handle, void *mapbase, size_t mapsize, int refcnt, const char *name) { struct utrace_rtld ut; - static const char rtld_utrace_sig[RTLD_UTRACE_SIG_SZ] = RTLD_UTRACE_SIG; + __nonstring static const char rtld_utrace_sig[RTLD_UTRACE_SIG_SZ] = RTLD_UTRACE_SIG; memset(&ut, 0, sizeof(ut)); /* clear holes */ memcpy(ut.sig, rtld_utrace_sig, sizeof(ut.sig));