Message ID | 20220204165834.GI2646553@tucnak |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3678A3858D3C for <patchwork@sourceware.org>; Fri, 4 Feb 2022 16:59:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3678A3858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1643993954; bh=DT5PXavABq9+z4iZOVckzh24WBDgQFRWEcWLHgvvBAo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=mr4q8n/xdGgewUFfEmuFpXDc8t/BARv45h0Gi92vmXLoaGKnL1L2WKxqorLwdyVNv yfhQPhESFZzX5nIvkXLTLn5SiNl7xzx+OR2rheSZVxe1NsQ5o1X2dK9+cW4fYg140I eGaAT24Cl+Mtob42u7DSOlH9pOiDSb6WcuAxlN08= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D93003858D20 for <gcc-patches@gcc.gnu.org>; Fri, 4 Feb 2022 16:58:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D93003858D20 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-264-ro3Ui0dTNaibizjxmXf0XA-1; Fri, 04 Feb 2022 11:58:41 -0500 X-MC-Unique: ro3Ui0dTNaibizjxmXf0XA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D38B84DA43; Fri, 4 Feb 2022 16:58:40 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA3B92B5A0; Fri, 4 Feb 2022 16:58:39 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 214GwaeF142532 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 4 Feb 2022 17:58:36 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 214GwYRg142531; Fri, 4 Feb 2022 17:58:34 +0100 Date: Fri, 4 Feb 2022 17:58:34 +0100 To: Segher Boessenkool <segher@kernel.crashing.org>, David Edelsohn <dje.gcc@gmail.com> Subject: [PATCH] rs6000: Fix up -D_FORTIFY_SOURCE* with -mabi=ieeelongdouble [PR104380] Message-ID: <20220204165834.GI2646553@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jakub Jelinek <jakub@redhat.com> Cc: Bill Schmidt <wschmidt@linux.ibm.com>, gcc-patches@gcc.gnu.org, Michael Meissner <meissner@linux.ibm.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
rs6000: Fix up -D_FORTIFY_SOURCE* with -mabi=ieeelongdouble [PR104380]
|
|
Commit Message
Jakub Jelinek
Feb. 4, 2022, 4:58 p.m. UTC
Hi! The following testcase FAILs when configured with --with-long-double-format=ieee . Only happens in the -std=c* modes, not the GNU modes; while the glibc headers have __asm redirects of vsnprintf and __vsnprinf_chk to __vsnprintfieee128 and __vsnprintf_chkieee128, the vsnprintf fortification extern inline gnu_inline always_inline wrapper calls __builtin_vsnprintf_chk and we actually emit a call to __vsnprinf_chk (i.e. with IBM extended long double) instead of __vsnprintf_chkieee128. rs6000_mangle_decl_assembler_name already had cases for *printf and *scanf, so this just adds another case for *printf_chk. *scanf_chk doesn't exist. __ prefixing isn't done because *printf_chk already starts with __. Bootstrapped/regtested on powerpc64le-linux, ok for trunk? 2022-02-04 Jakub Jelinek <jakub@redhat.com> PR target/104380 * config/rs6000/rs6000.cc (rs6000_mangle_decl_assembler_name): Also adjust mangling of __builtin*printf_chk. * gcc.dg/pr104380.c: New test. Jakub
Comments
On Fri, Feb 4, 2022 at 11:58 AM Jakub Jelinek <jakub@redhat.com> wrote: > > Hi! > > The following testcase FAILs when configured with > --with-long-double-format=ieee . Only happens in the -std=c* modes, not the > GNU modes; while the glibc headers have __asm redirects of > vsnprintf and __vsnprinf_chk to __vsnprintfieee128 and > __vsnprintf_chkieee128, the vsnprintf fortification extern inline gnu_inline > always_inline wrapper calls __builtin_vsnprintf_chk and we actually emit > a call to __vsnprinf_chk (i.e. with IBM extended long double) instead of > __vsnprintf_chkieee128. > > rs6000_mangle_decl_assembler_name already had cases for *printf and *scanf, > so this just adds another case for *printf_chk. *scanf_chk doesn't exist. > __ prefixing isn't done because *printf_chk already starts with __. > > Bootstrapped/regtested on powerpc64le-linux, ok for trunk? Okay. Thanks, David > > 2022-02-04 Jakub Jelinek <jakub@redhat.com> > > PR target/104380 > * config/rs6000/rs6000.cc (rs6000_mangle_decl_assembler_name): Also > adjust mangling of __builtin*printf_chk. > > * gcc.dg/pr104380.c: New test. > > --- gcc/config/rs6000/rs6000.cc.jj 2022-01-28 10:01:41.224837656 +0100 > +++ gcc/config/rs6000/rs6000.cc 2022-02-04 12:31:27.651715472 +0100 > @@ -28228,6 +28228,7 @@ rs6000_mangle_decl_assembler_name (tree > { > size_t printf_len = strlen ("printf"); > size_t scanf_len = strlen ("scanf"); > + size_t printf_chk_len = strlen ("printf_chk"); > > if (len >= printf_len > && strcmp (name + len - printf_len, "printf") == 0) > @@ -28237,6 +28238,10 @@ rs6000_mangle_decl_assembler_name (tree > && strcmp (name + len - scanf_len, "scanf") == 0) > newname = xasprintf ("__isoc99_%sieee128", name); > > + else if (len >= printf_chk_len > + && strcmp (name + len - printf_chk_len, "printf_chk") == 0) > + newname = xasprintf ("%sieee128", name); > + > else if (name[len - 1] == 'l') > { > bool uses_ieee128_p = false; > --- gcc/testsuite/gcc.dg/pr104380.c.jj 2022-02-04 12:51:50.152643364 +0100 > +++ gcc/testsuite/gcc.dg/pr104380.c 2022-02-04 12:53:25.092317741 +0100 > @@ -0,0 +1,32 @@ > +/* PR target/104380 */ > +/* This test needs runtime that provides __*_chk functions. */ > +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ > +/* { dg-options "-O2 -std=c99" } */ > + > +#define FORTIFY_SOURCE 2 > +#include <stdio.h> > +#include <stdarg.h> > + > +static char buf[4096]; > +static char gfmt[] = "%Lg"; > + > +static int __attribute__ ((noipa)) > +foo (char *str, const char *fmt, ...) > +{ > + int ret; > + va_list ap; > + va_start (ap, fmt); > + ret = vsnprintf (str, 4096, fmt, ap); > + va_end (ap); > + return ret; > +} > + > +int > +main () > +{ > + long double dval = 128.0L; > + int ret = foo (buf, gfmt, dval); > + if (ret != 3 || __builtin_strcmp (buf, "128") != 0) > + __builtin_abort (); > + return 0; > +} > > Jakub >
On Fri, Feb 04, 2022 at 12:00:57PM -0500, David Edelsohn via Gcc-patches wrote: > > The following testcase FAILs when configured with > > --with-long-double-format=ieee . Only happens in the -std=c* modes, not the > > GNU modes; while the glibc headers have __asm redirects of > > vsnprintf and __vsnprinf_chk to __vsnprintfieee128 and > > __vsnprintf_chkieee128, the vsnprintf fortification extern inline gnu_inline > > always_inline wrapper calls __builtin_vsnprintf_chk and we actually emit > > a call to __vsnprinf_chk (i.e. with IBM extended long double) instead of > > __vsnprintf_chkieee128. > > > > rs6000_mangle_decl_assembler_name already had cases for *printf and *scanf, > > so this just adds another case for *printf_chk. *scanf_chk doesn't exist. > > __ prefixing isn't done because *printf_chk already starts with __. > > > > Bootstrapped/regtested on powerpc64le-linux, ok for trunk? > > Okay. Unfortunately, while I've tested the testcase also with -mabi=ieeelongdouble by hand, the full bootstrap/regtest was on GCCFarm where glibc is too old to test with --with-long-double-format=ieee. I've done full bootstrap/regtest with that option during the weekend and the patch regressed: FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -O1 FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -O2 FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -O3 -g FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -Og -g FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -Os FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -O1 FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -O2 FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -O3 -g FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -Og -g FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -Os FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -O1 FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -O2 FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -O3 -g FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -Og -g FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -Os FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -O1 FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -O2 FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -O3 -g FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -Og -g FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -Os The problem is that the execute/builtins/ testsuite wants to override some of the library functions and with the change we (correctly) call __*printf_chkieee128 and so lib/chk.c is no longer called but the glibc APIs are. The following patch fixes it. Tested on powerpc64le-linux, ok for trunk? 2022-02-07 Jakub Jelinek <jakub@redhat.com> PR target/104380 * gcc.c-torture/execute/builtins/lib/chk.c (__sprintf_chkieee128, __vsprintf_chkieee128, __snprintf_chkieee128, __vsnprintf_chkieee128): New aliases to non-ieee128 suffixed functions for powerpc -mabi=ieeelongdouble. --- gcc/testsuite/gcc.c-torture/execute/builtins/lib/chk.c.jj 2022-01-05 20:30:08.852805055 +0100 +++ gcc/testsuite/gcc.c-torture/execute/builtins/lib/chk.c 2022-02-07 13:10:51.474447998 +0100 @@ -517,3 +517,14 @@ vsnprintf (char *str, __SIZE_TYPE__ len, return ret; } #endif + +#if defined(__powerpc__) && defined(__LONG_DOUBLE_IEEE128__) +__typeof (__sprintf_chk) __sprintf_chkieee128 + __attribute__((alias ("__sprintf_chk"))); +__typeof (__vsprintf_chk) __vsprintf_chkieee128 + __attribute__((alias ("__vsprintf_chk"))); +__typeof (__snprintf_chk) __snprintf_chkieee128 + __attribute__((alias ("__snprintf_chk"))); +__typeof (__vsnprintf_chk) __vsnprintf_chkieee128 + __attribute__((alias ("__vsnprintf_chk"))); +#endif Jakub
On Mon, Feb 7, 2022 at 8:20 AM Jakub Jelinek <jakub@redhat.com> wrote: > > On Fri, Feb 04, 2022 at 12:00:57PM -0500, David Edelsohn via Gcc-patches wrote: > > > The following testcase FAILs when configured with > > > --with-long-double-format=ieee . Only happens in the -std=c* modes, not the > > > GNU modes; while the glibc headers have __asm redirects of > > > vsnprintf and __vsnprinf_chk to __vsnprintfieee128 and > > > __vsnprintf_chkieee128, the vsnprintf fortification extern inline gnu_inline > > > always_inline wrapper calls __builtin_vsnprintf_chk and we actually emit > > > a call to __vsnprinf_chk (i.e. with IBM extended long double) instead of > > > __vsnprintf_chkieee128. > > > > > > rs6000_mangle_decl_assembler_name already had cases for *printf and *scanf, > > > so this just adds another case for *printf_chk. *scanf_chk doesn't exist. > > > __ prefixing isn't done because *printf_chk already starts with __. > > > > > > Bootstrapped/regtested on powerpc64le-linux, ok for trunk? > > > > Okay. > > Unfortunately, while I've tested the testcase also with -mabi=ieeelongdouble > by hand, the full bootstrap/regtest was on GCCFarm where glibc is too old > to test with --with-long-double-format=ieee. > I've done full bootstrap/regtest with that option during the weekend and > the patch regressed: > FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -O1 > FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -O2 > FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none > FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects > FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions > FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -O3 -g > FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -Og -g > FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution, -Os > FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -O1 > FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -O2 > FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none > FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects > FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions > FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -O3 -g > FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -Og -g > FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution, -Os > FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -O1 > FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -O2 > FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none > FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects > FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions > FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -O3 -g > FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -Og -g > FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution, -Os > FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -O1 > FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -O2 > FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none > FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects > FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions > FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -O3 -g > FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -Og -g > FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution, -Os > > The problem is that the execute/builtins/ testsuite wants to override some > of the library functions and with the change we (correctly) call > __*printf_chkieee128 and so lib/chk.c is no longer called but the glibc > APIs are. > > The following patch fixes it. > > Tested on powerpc64le-linux, ok for trunk? Okay. Thanks, David > > 2022-02-07 Jakub Jelinek <jakub@redhat.com> > > PR target/104380 > * gcc.c-torture/execute/builtins/lib/chk.c (__sprintf_chkieee128, > __vsprintf_chkieee128, __snprintf_chkieee128, > __vsnprintf_chkieee128): New aliases to non-ieee128 suffixed functions > for powerpc -mabi=ieeelongdouble. > > --- gcc/testsuite/gcc.c-torture/execute/builtins/lib/chk.c.jj 2022-01-05 20:30:08.852805055 +0100 > +++ gcc/testsuite/gcc.c-torture/execute/builtins/lib/chk.c 2022-02-07 13:10:51.474447998 +0100 > @@ -517,3 +517,14 @@ vsnprintf (char *str, __SIZE_TYPE__ len, > return ret; > } > #endif > + > +#if defined(__powerpc__) && defined(__LONG_DOUBLE_IEEE128__) > +__typeof (__sprintf_chk) __sprintf_chkieee128 > + __attribute__((alias ("__sprintf_chk"))); > +__typeof (__vsprintf_chk) __vsprintf_chkieee128 > + __attribute__((alias ("__vsprintf_chk"))); > +__typeof (__snprintf_chk) __snprintf_chkieee128 > + __attribute__((alias ("__snprintf_chk"))); > +__typeof (__vsnprintf_chk) __vsnprintf_chkieee128 > + __attribute__((alias ("__vsnprintf_chk"))); > +#endif > > > Jakub >
--- gcc/config/rs6000/rs6000.cc.jj 2022-01-28 10:01:41.224837656 +0100 +++ gcc/config/rs6000/rs6000.cc 2022-02-04 12:31:27.651715472 +0100 @@ -28228,6 +28228,7 @@ rs6000_mangle_decl_assembler_name (tree { size_t printf_len = strlen ("printf"); size_t scanf_len = strlen ("scanf"); + size_t printf_chk_len = strlen ("printf_chk"); if (len >= printf_len && strcmp (name + len - printf_len, "printf") == 0) @@ -28237,6 +28238,10 @@ rs6000_mangle_decl_assembler_name (tree && strcmp (name + len - scanf_len, "scanf") == 0) newname = xasprintf ("__isoc99_%sieee128", name); + else if (len >= printf_chk_len + && strcmp (name + len - printf_chk_len, "printf_chk") == 0) + newname = xasprintf ("%sieee128", name); + else if (name[len - 1] == 'l') { bool uses_ieee128_p = false; --- gcc/testsuite/gcc.dg/pr104380.c.jj 2022-02-04 12:51:50.152643364 +0100 +++ gcc/testsuite/gcc.dg/pr104380.c 2022-02-04 12:53:25.092317741 +0100 @@ -0,0 +1,32 @@ +/* PR target/104380 */ +/* This test needs runtime that provides __*_chk functions. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -std=c99" } */ + +#define FORTIFY_SOURCE 2 +#include <stdio.h> +#include <stdarg.h> + +static char buf[4096]; +static char gfmt[] = "%Lg"; + +static int __attribute__ ((noipa)) +foo (char *str, const char *fmt, ...) +{ + int ret; + va_list ap; + va_start (ap, fmt); + ret = vsnprintf (str, 4096, fmt, ap); + va_end (ap); + return ret; +} + +int +main () +{ + long double dval = 128.0L; + int ret = foo (buf, gfmt, dval); + if (ret != 3 || __builtin_strcmp (buf, "128") != 0) + __builtin_abort (); + return 0; +}