public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7059] rs6000: Fix up -D_FORTIFY_SOURCE* with -mabi=ieeelongdouble [PR104380] Date: Fri, 4 Feb 2022 17:31:40 +0000 (GMT) [thread overview] Message-ID: <20220204173140.C7D7A3858D20@sourceware.org> (raw) https://gcc.gnu.org/g:8d6fffc4bcd4afa0beb0efad4f3b95394aa15618 commit r12-7059-g8d6fffc4bcd4afa0beb0efad4f3b95394aa15618 Author: Jakub Jelinek <jakub@redhat.com> Date: Fri Feb 4 18:30:59 2022 +0100 rs6000: Fix up -D_FORTIFY_SOURCE* with -mabi=ieeelongdouble [PR104380] 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 __. 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. Diff: --- gcc/config/rs6000/rs6000.cc | 5 +++++ gcc/testsuite/gcc.dg/pr104380.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index b6f2309adfb..d9fc67d5d29 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -28069,6 +28069,7 @@ rs6000_mangle_decl_assembler_name (tree decl, tree id) { 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) @@ -28078,6 +28079,10 @@ rs6000_mangle_decl_assembler_name (tree decl, tree id) && 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; diff --git a/gcc/testsuite/gcc.dg/pr104380.c b/gcc/testsuite/gcc.dg/pr104380.c new file mode 100644 index 00000000000..54b2a87cf44 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr104380.c @@ -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; +}
reply other threads:[~2022-02-04 17:31 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220204173140.C7D7A3858D20@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).