summaryrefslogtreecommitdiff
path: root/include/bits
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2025-11-20 15:30:11 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2025-11-21 13:13:11 -0300
commit8d26bed1ebcefd5d2059fd7d7462bdf6593d77fa (patch)
treec48233a37c87ba56389fed5c6d2871a27e9318f4 /include/bits
parent25de0771ecac240a54f03ab55247d92457e4c310 (diff)
Enable --enable-fortify-source with clang
clang generates internal calls for some _chk symbol, so add internal aliases for them, and stub some with rtld-stubbed-symbols to avoid ld.so linker issues. Reviewed-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'include/bits')
-rw-r--r--include/bits/inet-fortified-decl.h5
-rw-r--r--include/bits/stdio2-decl.h7
-rw-r--r--include/bits/string_fortified.h15
-rw-r--r--include/bits/syslog-decl.h4
-rw-r--r--include/bits/unistd-decl.h6
-rw-r--r--include/bits/wchar2-decl.h5
6 files changed, 42 insertions, 0 deletions
diff --git a/include/bits/inet-fortified-decl.h b/include/bits/inet-fortified-decl.h
index e6ad4d4663..1110ce49f2 100644
--- a/include/bits/inet-fortified-decl.h
+++ b/include/bits/inet-fortified-decl.h
@@ -1 +1,6 @@
#include <inet/bits/inet-fortified-decl.h>
+
+#ifndef _ISOMAC
+libc_hidden_proto (__inet_ntop_chk)
+libc_hidden_proto (__inet_pton_chk)
+#endif
diff --git a/include/bits/stdio2-decl.h b/include/bits/stdio2-decl.h
index bbb052f192..9758bf4b55 100644
--- a/include/bits/stdio2-decl.h
+++ b/include/bits/stdio2-decl.h
@@ -1 +1,8 @@
#include <libio/bits/stdio2-decl.h>
+
+#ifndef _ISOMAC
+libc_hidden_proto (__fgets_unlocked_chk)
+libc_hidden_ldbl_proto (vfprintf)
+libc_hidden_ldbl_proto (__vasprintf_chk)
+libc_hidden_ldbl_proto (__vfprintf_chk)
+#endif
diff --git a/include/bits/string_fortified.h b/include/bits/string_fortified.h
index 88bf073c9c..0cf0e76db1 100644
--- a/include/bits/string_fortified.h
+++ b/include/bits/string_fortified.h
@@ -1 +1,16 @@
+#ifndef _ISOMAC
+# if IS_IN(libc) && defined SHARED
+/* Redirect calls from __builtin_stpcpy_chk to internal __stpcpy when building
+ with fortify enable. */
+__asm__ ("stpcpy = __GI___stpcpy");
+# endif
+
+/* Add the internal aliass attribute to symbol before they first usage on the
+ fortify wrappers. */
+libc_hidden_builtin_proto (memcpy)
+libc_hidden_builtin_proto (mempcpy)
+libc_hidden_builtin_proto (memmove)
+libc_hidden_builtin_proto (memset)
+#endif
+
#include <string/bits/string_fortified.h>
diff --git a/include/bits/syslog-decl.h b/include/bits/syslog-decl.h
index 491a263777..762b289184 100644
--- a/include/bits/syslog-decl.h
+++ b/include/bits/syslog-decl.h
@@ -1 +1,5 @@
#include <misc/bits/syslog-decl.h>
+
+#ifndef _ISOMAC
+libc_hidden_ldbl_proto (__vsyslog_chk)
+#endif
diff --git a/include/bits/unistd-decl.h b/include/bits/unistd-decl.h
index 7fcbd272ac..dd6af7e4c8 100644
--- a/include/bits/unistd-decl.h
+++ b/include/bits/unistd-decl.h
@@ -1 +1,7 @@
#include <posix/bits/unistd-decl.h>
+
+#ifndef _ISOMAC
+libc_hidden_proto (__read_chk)
+libc_hidden_proto (__getdomainname_chk)
+libc_hidden_proto (__getlogin_r_chk)
+#endif
diff --git a/include/bits/wchar2-decl.h b/include/bits/wchar2-decl.h
index 00b1b93342..f3b8a8cf87 100644
--- a/include/bits/wchar2-decl.h
+++ b/include/bits/wchar2-decl.h
@@ -1 +1,6 @@
#include <wcsmbs/bits/wchar2-decl.h>
+
+#ifndef _ISOMAC
+libc_hidden_builtin_proto (__wmemset_chk)
+libc_hidden_proto (__wcrtomb_chk)
+#endif