From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe33.google.com (mail-vs1-xe33.google.com [IPv6:2607:f8b0:4864:20::e33]) by sourceware.org (Postfix) with ESMTPS id 30FC73858C2F for ; Thu, 25 Aug 2022 16:58:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 30FC73858C2F Received: by mail-vs1-xe33.google.com with SMTP id m66so21447635vsm.12 for ; Thu, 25 Aug 2022 09:58:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:cc:organization:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=e1r29HCgsrwcHnNM0DPovxCavGAq1s0SSwgPji6vghE=; b=6FKtg4y/48gRXIDvOfMl56hhurr5CJO8YA3HrgKiDQlBaVu01pQK2cCrRHzqjeSuDj sMRh/7nIQTYxckG2PaTefLAzLw6+lzVPcTAlOwsNvV/M6vRqQc/k2yEZxRZsm0KmiMPg kQF9aROAVdUo8ZdEunPI/D3khLweG7WdjOclBeS0I1i5C5r6AWGPN+yN9cxCDFoicyyf PVJ8IoPsoSVEqcytP84/8qQgvOysV4JINQGEjgPGiabV7Dc0pmGp+5Jsm02OZfdoHjjd W66YYgxR8FxNYX9kNEcquNRyVrlJFJwCY9yK53cdpEdk5KrYkxMrm5gw4yKohuN5rU+C hqng== X-Gm-Message-State: ACgBeo00KcO99xykyHUdNzEmJql7wqZu9FgdFG+iLg2O3kmvwMx9qHxl 03KTsf68dv700j7A5dpLKuJ9I3GdeYQn0Q== X-Google-Smtp-Source: AA6agR4diSL9b/2HrHt67bTBKxfSCp9ZulHINlKzbhiyUJcGCdZ7HQpRDe9xd/kujO7KOS0dAOleQQ== X-Received: by 2002:a67:c390:0:b0:390:3aa3:a329 with SMTP id s16-20020a67c390000000b003903aa3a329mr2096881vsj.82.1661446687243; Thu, 25 Aug 2022 09:58:07 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:745e:786a:689c:f1e5:7517? ([2804:1b3:a7c0:745e:786a:689c:f1e5:7517]) by smtp.gmail.com with ESMTPSA id h12-20020a1f9e0c000000b0037a772b119dsm16829057vke.36.2022.08.25.09.58.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Aug 2022 09:58:06 -0700 (PDT) Message-ID: <50ba1c79-b88f-bc6b-3bb0-331157ba33e3@linaro.org> Date: Thu, 25 Aug 2022 13:58:04 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: [PATCH] Apply asm redirections in wchar.h before first use Content-Language: en-US To: libc-alpha@sourceware.org, Raphael Moreira Zinsly References: <20220824144337.16153-1-rzinsly@linux.ibm.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <20220824144337.16153-1-rzinsly@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Aug 2022 16:58:11 -0000 Message-ID: <20220825165804.v6kfpQ_lYz_fl1drstrSm-YTbwRUML2JbMEpzrmqBA8@z> On 24/08/22 11:43, Raphael Moreira Zinsly via Libc-alpha wrote: > Similar to d0fa09a770, but for wchar.h. Fixes [BZ #27087] by applying > all long double related asm redirections before using functions in > bits/wchar2.h. > Moves the function declarations from wcsmbs/bits/wchar2.h to a new file > wcsmbs/bits/wchar2-decl.h that will be included first in wcsmbs/wchar.h. > > Tested with build-many-glibcs.py. LGTM, thanks. Reviewed-by: Adhemerval Zanella > --- > include/bits/wchar2-decl.h | 1 + > wcsmbs/Makefile | 5 +- > wcsmbs/bits/wchar2-decl.h | 124 +++++++++++++++++++++++++++++++++++++ > wcsmbs/bits/wchar2.h | 72 --------------------- > wcsmbs/wchar.h | 11 +++- > 5 files changed, 137 insertions(+), 76 deletions(-) > create mode 100644 include/bits/wchar2-decl.h > create mode 100644 wcsmbs/bits/wchar2-decl.h > > diff --git a/include/bits/wchar2-decl.h b/include/bits/wchar2-decl.h > new file mode 100644 > index 0000000000..00b1b93342 > --- /dev/null > +++ b/include/bits/wchar2-decl.h > @@ -0,0 +1 @@ > +#include > diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile > index 3d19d5556f..4af102a3f6 100644 > --- a/wcsmbs/Makefile > +++ b/wcsmbs/Makefile > @@ -22,8 +22,9 @@ subdir := wcsmbs > > include ../Makeconfig > > -headers := wchar.h bits/wchar.h bits/wchar2.h bits/wchar-ldbl.h uchar.h \ > - bits/types/__mbstate_t.h bits/types/mbstate_t.h bits/types/wint_t.h > +headers := wchar.h bits/wchar.h bits/wchar2.h bits/wchar2-decl.h \ > + bits/wchar-ldbl.h uchar.h bits/types/__mbstate_t.h \ > + bits/types/mbstate_t.h bits/types/wint_t.h > > routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \ > wcsncmp wcsncpy wcspbrk wcsrchr wcsspn wcstok wcsstr wmemchr \ Ok. > diff --git a/wcsmbs/bits/wchar2-decl.h b/wcsmbs/bits/wchar2-decl.h > new file mode 100644 > index 0000000000..8e1735c33b > --- /dev/null > +++ b/wcsmbs/bits/wchar2-decl.h > @@ -0,0 +1,124 @@ > +/* Checking macros for wchar functions. Declarations only. > + Copyright (C) 2004-2022 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#ifndef _BITS_WCHAR2_DECL_H > +#define _BITS_WCHAR2_DECL_H 1 > + > +#ifndef _WCHAR_H > +# error "Never include directly; use instead." > +#endif > + > + > +extern wchar_t *__wmemcpy_chk (wchar_t *__restrict __s1, > + const wchar_t *__restrict __s2, size_t __n, > + size_t __ns1) __THROW; > +extern wchar_t *__wmemmove_chk (wchar_t *__s1, const wchar_t *__s2, > + size_t __n, size_t __ns1) __THROW; > + > + > +#ifdef __USE_GNU > + > +extern wchar_t *__wmempcpy_chk (wchar_t *__restrict __s1, > + const wchar_t *__restrict __s2, size_t __n, > + size_t __ns1) __THROW; > + > +#endif > + > + > +extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n, > + size_t __ns) __THROW; > +extern wchar_t *__wcscpy_chk (wchar_t *__restrict __dest, > + const wchar_t *__restrict __src, > + size_t __n) __THROW; > +extern wchar_t *__wcpcpy_chk (wchar_t *__restrict __dest, > + const wchar_t *__restrict __src, > + size_t __destlen) __THROW; > +extern wchar_t *__wcsncpy_chk (wchar_t *__restrict __dest, > + const wchar_t *__restrict __src, size_t __n, > + size_t __destlen) __THROW; > +extern wchar_t *__wcpncpy_chk (wchar_t *__restrict __dest, > + const wchar_t *__restrict __src, size_t __n, > + size_t __destlen) __THROW; > +extern wchar_t *__wcscat_chk (wchar_t *__restrict __dest, > + const wchar_t *__restrict __src, > + size_t __destlen) __THROW; > +extern wchar_t *__wcsncat_chk (wchar_t *__restrict __dest, > + const wchar_t *__restrict __src, > + size_t __n, size_t __destlen) __THROW; > +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 __vswprintf_chk (wchar_t *__restrict __s, size_t __n, > + int __flag, size_t __s_len, > + const wchar_t *__restrict __format, > + __gnuc_va_list __arg) > + __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */; > + > +#if __USE_FORTIFY_LEVEL > 1 > + > +extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag, > + const wchar_t *__restrict __format, ...); > +extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format, > + ...); > +extern int __vfwprintf_chk (__FILE *__restrict __stream, int __flag, > + const wchar_t *__restrict __format, > + __gnuc_va_list __ap); > +extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format, > + __gnuc_va_list __ap); > + > +#endif > + > +extern wchar_t *__fgetws_chk (wchar_t *__restrict __s, size_t __size, int __n, > + __FILE *__restrict __stream) __wur; > + > +#ifdef __USE_GNU > + > +extern wchar_t *__fgetws_unlocked_chk (wchar_t *__restrict __s, size_t __size, > + int __n, __FILE *__restrict __stream) > + __wur; > + > +#endif > + > +extern size_t __wcrtomb_chk (char *__restrict __s, wchar_t __wchar, > + mbstate_t *__restrict __p, > + size_t __buflen) __THROW __wur; > +extern size_t __mbsrtowcs_chk (wchar_t *__restrict __dst, > + const char **__restrict __src, > + size_t __len, mbstate_t *__restrict __ps, > + size_t __dstlen) __THROW; > +extern size_t __wcsrtombs_chk (char *__restrict __dst, > + const wchar_t **__restrict __src, > + size_t __len, mbstate_t *__restrict __ps, > + size_t __dstlen) __THROW; > + > +#ifdef __USE_XOPEN2K8 > + > +extern size_t __mbsnrtowcs_chk (wchar_t *__restrict __dst, > + const char **__restrict __src, size_t __nmc, > + size_t __len, mbstate_t *__restrict __ps, > + size_t __dstlen) __THROW; > +extern size_t __wcsnrtombs_chk (char *__restrict __dst, > + const wchar_t **__restrict __src, > + size_t __nwc, size_t __len, > + mbstate_t *__restrict __ps, size_t __dstlen) > + __THROW; > + > +#endif > + > +#endif /* bits/wchar2-decl.h. */ Ok. > diff --git a/wcsmbs/bits/wchar2.h b/wcsmbs/bits/wchar2.h > index 0e017f458b..3f110efe57 100644 > --- a/wcsmbs/bits/wchar2.h > +++ b/wcsmbs/bits/wchar2.h > @@ -21,9 +21,6 @@ > #endif > > > -extern wchar_t *__wmemcpy_chk (wchar_t *__restrict __s1, > - const wchar_t *__restrict __s2, size_t __n, > - size_t __ns1) __THROW; > extern wchar_t *__REDIRECT_NTH (__wmemcpy_alias, > (wchar_t *__restrict __s1, > const wchar_t *__restrict __s2, size_t __n), > @@ -45,8 +42,6 @@ __NTH (wmemcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2, > } > > > -extern wchar_t *__wmemmove_chk (wchar_t *__s1, const wchar_t *__s2, > - size_t __n, size_t __ns1) __THROW; > extern wchar_t *__REDIRECT_NTH (__wmemmove_alias, (wchar_t *__s1, > const wchar_t *__s2, > size_t __n), wmemmove); > @@ -66,9 +61,6 @@ __NTH (wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)) > > > #ifdef __USE_GNU > -extern wchar_t *__wmempcpy_chk (wchar_t *__restrict __s1, > - const wchar_t *__restrict __s2, size_t __n, > - size_t __ns1) __THROW; > extern wchar_t *__REDIRECT_NTH (__wmempcpy_alias, > (wchar_t *__restrict __s1, > const wchar_t *__restrict __s2, > @@ -91,8 +83,6 @@ __NTH (wmempcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2, > #endif > > > -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, > size_t __n), wmemset); > extern wchar_t *__REDIRECT_NTH (__wmemset_chk_warn, > @@ -110,9 +100,6 @@ __NTH (wmemset (wchar_t *__s, wchar_t __c, size_t __n)) > } > > > -extern wchar_t *__wcscpy_chk (wchar_t *__restrict __dest, > - const wchar_t *__restrict __src, > - size_t __n) __THROW; > extern wchar_t *__REDIRECT_NTH (__wcscpy_alias, > (wchar_t *__restrict __dest, > const wchar_t *__restrict __src), wcscpy); > @@ -127,9 +114,6 @@ __NTH (wcscpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) > } > > > -extern wchar_t *__wcpcpy_chk (wchar_t *__restrict __dest, > - const wchar_t *__restrict __src, > - size_t __destlen) __THROW; > extern wchar_t *__REDIRECT_NTH (__wcpcpy_alias, > (wchar_t *__restrict __dest, > const wchar_t *__restrict __src), wcpcpy); > @@ -144,9 +128,6 @@ __NTH (wcpcpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) > } > > > -extern wchar_t *__wcsncpy_chk (wchar_t *__restrict __dest, > - const wchar_t *__restrict __src, size_t __n, > - size_t __destlen) __THROW; > extern wchar_t *__REDIRECT_NTH (__wcsncpy_alias, > (wchar_t *__restrict __dest, > const wchar_t *__restrict __src, > @@ -168,9 +149,6 @@ __NTH (wcsncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src, > } > > > -extern wchar_t *__wcpncpy_chk (wchar_t *__restrict __dest, > - const wchar_t *__restrict __src, size_t __n, > - size_t __destlen) __THROW; > extern wchar_t *__REDIRECT_NTH (__wcpncpy_alias, > (wchar_t *__restrict __dest, > const wchar_t *__restrict __src, > @@ -192,9 +170,6 @@ __NTH (wcpncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src, > } > > > -extern wchar_t *__wcscat_chk (wchar_t *__restrict __dest, > - const wchar_t *__restrict __src, > - size_t __destlen) __THROW; > extern wchar_t *__REDIRECT_NTH (__wcscat_alias, > (wchar_t *__restrict __dest, > const wchar_t *__restrict __src), wcscat); > @@ -209,9 +184,6 @@ __NTH (wcscat (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) > } > > > -extern wchar_t *__wcsncat_chk (wchar_t *__restrict __dest, > - const wchar_t *__restrict __src, > - size_t __n, size_t __destlen) __THROW; > extern wchar_t *__REDIRECT_NTH (__wcsncat_alias, > (wchar_t *__restrict __dest, > const wchar_t *__restrict __src, > @@ -228,10 +200,6 @@ __NTH (wcsncat (wchar_t *__restrict __dest, const wchar_t *__restrict __src, > } > > > -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 __REDIRECT_NTH_LDBL (__swprintf_alias, > (wchar_t *__restrict __s, size_t __n, > @@ -258,11 +226,6 @@ __NTH (swprintf (wchar_t *__restrict __s, size_t __n, > : swprintf (s, n, __VA_ARGS__)) > #endif > > -extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n, > - int __flag, size_t __s_len, > - const wchar_t *__restrict __format, > - __gnuc_va_list __arg) > - __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */; > > extern int __REDIRECT_NTH_LDBL (__vswprintf_alias, > (wchar_t *__restrict __s, size_t __n, > @@ -283,16 +246,6 @@ __NTH (vswprintf (wchar_t *__restrict __s, size_t __n, > > #if __USE_FORTIFY_LEVEL > 1 > > -extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag, > - const wchar_t *__restrict __format, ...); > -extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format, > - ...); > -extern int __vfwprintf_chk (__FILE *__restrict __stream, int __flag, > - const wchar_t *__restrict __format, > - __gnuc_va_list __ap); > -extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format, > - __gnuc_va_list __ap); > - > # ifdef __va_arg_pack > __fortify_function int > wprintf (const wchar_t *__restrict __fmt, ...) > @@ -328,8 +281,6 @@ vfwprintf (__FILE *__restrict __stream, > > #endif > > -extern wchar_t *__fgetws_chk (wchar_t *__restrict __s, size_t __size, int __n, > - __FILE *__restrict __stream) __wur; > extern wchar_t *__REDIRECT (__fgetws_alias, > (wchar_t *__restrict __s, int __n, > __FILE *__restrict __stream), fgetws) __wur; > @@ -351,9 +302,6 @@ fgetws (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream) > } > > #ifdef __USE_GNU > -extern wchar_t *__fgetws_unlocked_chk (wchar_t *__restrict __s, size_t __size, > - int __n, __FILE *__restrict __stream) > - __wur; > extern wchar_t *__REDIRECT (__fgetws_unlocked_alias, > (wchar_t *__restrict __s, int __n, > __FILE *__restrict __stream), fgetws_unlocked) > @@ -379,9 +327,6 @@ fgetws_unlocked (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream) > #endif > > > -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, > (char *__restrict __s, wchar_t __wchar, > mbstate_t *__restrict __ps), wcrtomb) __wur; > @@ -404,10 +349,6 @@ __NTH (wcrtomb (char *__restrict __s, wchar_t __wchar, > } > > > -extern size_t __mbsrtowcs_chk (wchar_t *__restrict __dst, > - const char **__restrict __src, > - size_t __len, mbstate_t *__restrict __ps, > - size_t __dstlen) __THROW; > extern size_t __REDIRECT_NTH (__mbsrtowcs_alias, > (wchar_t *__restrict __dst, > const char **__restrict __src, > @@ -431,10 +372,6 @@ __NTH (mbsrtowcs (wchar_t *__restrict __dst, const char **__restrict __src, > } > > > -extern size_t __wcsrtombs_chk (char *__restrict __dst, > - const wchar_t **__restrict __src, > - size_t __len, mbstate_t *__restrict __ps, > - size_t __dstlen) __THROW; > extern size_t __REDIRECT_NTH (__wcsrtombs_alias, > (char *__restrict __dst, > const wchar_t **__restrict __src, > @@ -458,10 +395,6 @@ __NTH (wcsrtombs (char *__restrict __dst, const wchar_t **__restrict __src, > > > #ifdef __USE_XOPEN2K8 > -extern size_t __mbsnrtowcs_chk (wchar_t *__restrict __dst, > - const char **__restrict __src, size_t __nmc, > - size_t __len, mbstate_t *__restrict __ps, > - size_t __dstlen) __THROW; > extern size_t __REDIRECT_NTH (__mbsnrtowcs_alias, > (wchar_t *__restrict __dst, > const char **__restrict __src, size_t __nmc, > @@ -485,11 +418,6 @@ __NTH (mbsnrtowcs (wchar_t *__restrict __dst, const char **__restrict __src, > } > > > -extern size_t __wcsnrtombs_chk (char *__restrict __dst, > - const wchar_t **__restrict __src, > - size_t __nwc, size_t __len, > - mbstate_t *__restrict __ps, size_t __dstlen) > - __THROW; > extern size_t __REDIRECT_NTH (__wcsnrtombs_alias, > (char *__restrict __dst, > const wchar_t **__restrict __src, Ok. > diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h > index 5d6a40853d..c1321c7518 100644 > --- a/wcsmbs/wchar.h > +++ b/wcsmbs/wchar.h > @@ -864,14 +864,21 @@ extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize, > > /* Define some macros helping to catch buffer overflows. */ > #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function > -# include > +/* Declare all functions from bits/wchar2-decl.h first. */ > +# include > #endif > > -#include > +/* The following headers provide asm redirections. These redirections must > + appear before the first usage of these functions, e.g. in bits/wchar.h. */ > #if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 > # include > #endif > > +#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function > +/* Now include the function definitions and redirects too. */ > +# include > +#endif > + > __END_DECLS > > #endif /* wchar.h */ Ok.