aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Bérat <fberat@redhat.com>2023-06-07 11:06:50 +0200
committerFrédéric Bérat <fberat@redhat.com>2023-07-05 16:59:48 +0200
commit64f9857507f6dbf9715350b75e83b465be9b8f03 (patch)
treeb176a051eb3b8de0c0969766edc8dc1d889946d4
parenteea000f6e69a829425fae25a7c2519f5c79551de (diff)
downloadglibc-64f9857507f6dbf9715350b75e83b465be9b8f03.zip
glibc-64f9857507f6dbf9715350b75e83b465be9b8f03.tar.gz
glibc-64f9857507f6dbf9715350b75e83b465be9b8f03.tar.bz2
wchar: Avoid PLT entries with _FORTIFY_SOURCE
The change is meant to avoid unwanted PLT entries for the wmemset and wcrtomb routines when _FORTIFY_SOURCE is set. On top of that, ensure that *_chk routines have their hidden builtin definitions available. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
-rw-r--r--debug/wcrtomb_chk.c1
-rw-r--r--debug/wmemset_chk.c1
-rw-r--r--include/wchar.h15
-rw-r--r--sysdeps/x86_64/multiarch/wmemset_chk.c4
-rw-r--r--wcsmbs/bits/wchar2-decl.h4
5 files changed, 23 insertions, 2 deletions
diff --git a/debug/wcrtomb_chk.c b/debug/wcrtomb_chk.c
index 657be74..c156fe0 100644
--- a/debug/wcrtomb_chk.c
+++ b/debug/wcrtomb_chk.c
@@ -28,3 +28,4 @@ __wcrtomb_chk (char *s, wchar_t wchar, mbstate_t *ps, size_t buflen)
{
return __wcrtomb_internal (s, wchar, ps, buflen);
}
+libc_hidden_def (__wcrtomb_chk)
diff --git a/debug/wmemset_chk.c b/debug/wmemset_chk.c
index e11a928..1e7fc4f 100644
--- a/debug/wmemset_chk.c
+++ b/debug/wmemset_chk.c
@@ -26,3 +26,4 @@ __wmemset_chk (wchar_t *s, wchar_t c, size_t n, size_t dstlen)
return wmemset (s, c, n);
}
+libc_hidden_builtin_def (__wmemset_chk)
diff --git a/include/wchar.h b/include/wchar.h
index 7b763bc..484e6b3 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -166,6 +166,8 @@ libc_hidden_proto (putwc)
libc_hidden_proto (mbrtowc)
libc_hidden_proto (wcrtomb)
+libc_hidden_proto (__wcrtomb_chk)
+
extern int __wcscmp (const wchar_t *__s1, const wchar_t *__s2)
__THROW __attribute_pure__;
libc_hidden_proto (__wcscmp)
@@ -260,16 +262,25 @@ extern wchar_t *__wcschrnul (const wchar_t *__s, wchar_t __wc)
extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n,
size_t __ns) __THROW;
+libc_hidden_builtin_proto (__wmemset_chk)
extern int __vfwscanf (__FILE *__restrict __s,
const wchar_t *__restrict __format,
__gnuc_va_list __arg)
attribute_hidden
/* __attribute__ ((__format__ (__wscanf__, 2, 0)) */;
+
+extern int __swprintf_chk (wchar_t *__restrict __s, size_t __n,
+ int __flag, size_t __s_len,
+ const wchar_t *__restrict __format, ...)
+ __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 6))) */;
+
extern int __fwprintf (__FILE *__restrict __s,
const wchar_t *__restrict __format, ...)
attribute_hidden
/* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
+extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format,
+ ...);
extern int __vfwprintf_chk (FILE *__restrict __s, int __flag,
const wchar_t *__restrict __format,
__gnuc_va_list __arg)
@@ -279,6 +290,10 @@ extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
const wchar_t *__restrict __format,
__gnuc_va_list __arg)
/* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
+extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag,
+ const wchar_t *__restrict __format, ...);
+extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format,
+ __gnuc_va_list __ap);
extern int __isoc99_fwscanf (__FILE *__restrict __stream,
const wchar_t *__restrict __format, ...);
diff --git a/sysdeps/x86_64/multiarch/wmemset_chk.c b/sysdeps/x86_64/multiarch/wmemset_chk.c
index ac93a1f..00edf44 100644
--- a/sysdeps/x86_64/multiarch/wmemset_chk.c
+++ b/sysdeps/x86_64/multiarch/wmemset_chk.c
@@ -28,4 +28,8 @@
libc_ifunc_redirected (__redirect_wmemset_chk, __wmemset_chk,
IFUNC_SELECTOR ());
+# ifdef SHARED
+__hidden_ver1 (__wmemset_chk, __GI___wmemset_chk, __redirect_wmemset_chk)
+ __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__wmemset_chk);
+# endif
#endif
diff --git a/wcsmbs/bits/wchar2-decl.h b/wcsmbs/bits/wchar2-decl.h
index f3a2fd3..08c8ebd 100644
--- a/wcsmbs/bits/wchar2-decl.h
+++ b/wcsmbs/bits/wchar2-decl.h
@@ -71,7 +71,7 @@ extern wchar_t *__REDIRECT_NTH (__wmempcpy_chk_warn,
extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n,
size_t __ns) __THROW;
-extern wchar_t *__REDIRECT_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c,
+extern wchar_t *__REDIRECT_FORTIFY_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c,
size_t __n), wmemset);
extern wchar_t *__REDIRECT_NTH (__wmemset_chk_warn,
(wchar_t *__s, wchar_t __c, size_t __n,
@@ -203,7 +203,7 @@ extern wchar_t *__REDIRECT (__fgetws_unlocked_chk_warn,
extern size_t __wcrtomb_chk (char *__restrict __s, wchar_t __wchar,
mbstate_t *__restrict __p,
size_t __buflen) __THROW __wur;
-extern size_t __REDIRECT_NTH (__wcrtomb_alias,
+extern size_t __REDIRECT_FORTIFY_NTH (__wcrtomb_alias,
(char *__restrict __s, wchar_t __wchar,
mbstate_t *__restrict __ps), wcrtomb) __wur;