From patchwork Mon Jun 4 16:58:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 27617 Received: (qmail 52295 invoked by alias); 4 Jun 2018 16:58:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 52262 invoked by uid 89); 4 Jun 2018 16:58:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.2 required=5.0 tests=AWL, BAYES_40, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=silence, sk:ppc64_e, bfdinh, UD:bfd-in.h X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-oi0-f67.google.com Received: from mail-oi0-f67.google.com (HELO mail-oi0-f67.google.com) (209.85.218.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Jun 2018 16:58:09 +0000 Received: by mail-oi0-f67.google.com with SMTP id c128-v6so19816479oig.11; Mon, 04 Jun 2018 09:58:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=MJhoVOyhxo3ccTgoV2I8EOayMrYDJo9Wr7/s0W+dvOs=; b=NLumIJfJD2ca899YdwjuJiYul6KviOuvoLoA2mn27Z9jGWFniSPOxgBvqxIWMkpA6R sBDr2D2vzYwv+Fvu1dxQ0cdJCJLx63ELXPEZW8FbxbAQuFTlBMCnCk5kznKYG52raoW/ yoZA1DHm5DW6XkPzKmtZzuFlIgdFR4A5gDYJCxkH6jpH9T3C8Vh5fh75TgqoBstTg9d5 6QhXf8bkeVJ0b0HKfpQ3T6Xls5SBgoxH+iKi3PDi1p0zBUqQUxwJJPT5pWs0mYJLDWJL lutg8AGaf+UxZq/QFGUfow9leeZNue+JmrmMWPkw++tGnQG8ghkZNnUKLZKjgJUW0eX0 65Xg== X-Gm-Message-State: ALKqPwdPMf9WOq9OmjbH2T5zZwekE96jhpxaP/wG1aHVPPuat9rs34WR /YgEfLmoDHaa4QGWztXZcZPKCw/jpjqYwTwNx0I= X-Google-Smtp-Source: ADUXVKLDhPQJx3Oe+9f5H3tLtA8nLvtkc+XbX5ZLtqCyMg3j29c/q4IrzCXIQF15CxB4aVGD8Ml3usT3MWSMWeHLDAU= X-Received: by 2002:aca:47c6:: with SMTP id u189-v6mr13240196oia.100.1528131488292; Mon, 04 Jun 2018 09:58:08 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4a:7019:0:0:0:0:0 with HTTP; Mon, 4 Jun 2018 09:58:07 -0700 (PDT) In-Reply-To: References: <20180521121557.16535-1-hjl.tools@gmail.com> <20180521121557.16535-3-hjl.tools@gmail.com> From: "H.J. Lu" Date: Mon, 4 Jun 2018 09:58:07 -0700 Message-ID: Subject: Re: [PATCH 3/3] Use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION to silence GCC 8 To: Nick Clifton , Pedro Alves Cc: Binutils , GDB X-IsSubscribed: yes On Fri, Jun 1, 2018 at 12:59 AM, Nick Clifton wrote: > Hi H.J. > >> PR binutils/23146 >> * bfd-in.h: Include "diagnostics.h". >> * bfd-in2.h: Regenerated. >> * elf32-arm.c (elf32_arm_nabi_write_core_note): Use >> DIAGNOSTIC_PUSH, DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION and >> DIAGNOSTIC_POP to silence GCC 8 warnings with >> -Wstringop-truncation. >> * elf32-ppc.c (ppc_elf_write_core_note): Likewse. >> * elf32-s390.c (elf_s390_write_core_note): Likewse. >> * elf64-ppc.c (ppc64_elf_write_core_note): Likewse. >> * elf64-s390.c (elf_s390_write_core_note): Likewse. >> * elfxx-aarch64.c (_bfd_aarch64_elf_write_core_note): Likewse. > > Approved - please apply. > This is the patch I am checking in. From 30a2bf66aa5b1a22ea14cbc5eb10d12cae5657c1 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 4 Jun 2018 09:48:28 -0700 Subject: [PATCH] Use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION to silence GCC 8.1 GCC 8.1 warns about destination size with -Wstringop-truncation: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 Use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION to silence it. bfd/ PR binutils/23146 * bfd-in.h: Include "diagnostics.h". * bfd-in2.h: Regenerated. * elf32-arm.c (elf32_arm_nabi_write_core_note): Use DIAGNOSTIC_PUSH, DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION and DIAGNOSTIC_POP to silence GCC 8.1 warnings with -Wstringop-truncation. * elf32-ppc.c (ppc_elf_write_core_note): Likewse. * elf32-s390.c (elf_s390_write_core_note): Likewse. * elf64-ppc.c (ppc64_elf_write_core_note): Likewse. * elf64-s390.c (elf_s390_write_core_note): Likewse. * elfxx-aarch64.c (_bfd_aarch64_elf_write_core_note): Likewse. include/ * diagnostics.h (DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION): Always define for GCC. --- bfd/bfd-in.h | 1 + bfd/bfd-in2.h | 1 + bfd/elf32-arm.c | 9 +++++++++ bfd/elf32-ppc.c | 9 +++++++++ bfd/elf32-s390.c | 9 +++++++++ bfd/elf64-ppc.c | 9 +++++++++ bfd/elf64-s390.c | 9 +++++++++ bfd/elfxx-aarch64.c | 9 +++++++++ include/diagnostics.h | 4 +--- 9 files changed, 57 insertions(+), 3 deletions(-) diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 481587e458..1d477c3f5f 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -34,6 +34,7 @@ extern "C" { #include "ansidecl.h" #include "symcat.h" +#include "diagnostics.h" #include #include diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index ef62f31953..65735f026e 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -41,6 +41,7 @@ extern "C" { #include "ansidecl.h" #include "symcat.h" +#include "diagnostics.h" #include #include diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index dbfd838fbe..870111b5ed 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -2174,7 +2174,16 @@ elf32_arm_nabi_write_core_note (bfd *abfd, char *buf, int *bufsiz, va_start (ap, note_type); memset (data, 0, sizeof (data)); strncpy (data + 28, va_arg (ap, const char *), 16); + DIAGNOSTIC_PUSH; + /* GCC 8.1 warns about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ +#if GCC_VERSION == 8001 + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; +#endif strncpy (data + 44, va_arg (ap, const char *), 80); + DIAGNOSTIC_POP; va_end (ap); return elfcore_write_note (abfd, buf, bufsiz, diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 3482baca20..ea8dbed981 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -2411,7 +2411,16 @@ ppc_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type, ...) va_start (ap, note_type); memset (data, 0, sizeof (data)); strncpy (data + 32, va_arg (ap, const char *), 16); + DIAGNOSTIC_PUSH; + /* GCC 8.1 warns about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ +#if GCC_VERSION == 8001 + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; +#endif strncpy (data + 48, va_arg (ap, const char *), 80); + DIAGNOSTIC_POP; va_end (ap); return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type, data, sizeof (data)); diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 99ceb76d3d..ebda1dacdc 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -3951,7 +3951,16 @@ elf_s390_write_core_note (bfd *abfd, char *buf, int *bufsiz, va_end (ap); strncpy (data + 28, fname, 16); + DIAGNOSTIC_PUSH; + /* GCC 8.1 warns about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ +#if GCC_VERSION == 8001 + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; +#endif strncpy (data + 44, psargs, 80); + DIAGNOSTIC_POP; return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type, &data, sizeof (data)); } diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index f543cb0288..16199fbe3e 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -3041,7 +3041,16 @@ ppc64_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type, va_start (ap, note_type); memset (data, 0, sizeof (data)); strncpy (data + 40, va_arg (ap, const char *), 16); + DIAGNOSTIC_PUSH; + /* GCC 8.1 warns about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ +#if GCC_VERSION == 8001 + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; +#endif strncpy (data + 56, va_arg (ap, const char *), 80); + DIAGNOSTIC_POP; va_end (ap); return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type, data, sizeof (data)); diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 612557fa74..93a3c7c22a 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -3760,7 +3760,16 @@ elf_s390_write_core_note (bfd *abfd, char *buf, int *bufsiz, va_end (ap); strncpy (data + 40, fname, 16); + DIAGNOSTIC_PUSH; + /* GCC 8.1 warns about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ +#if GCC_VERSION == 8001 + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; +#endif strncpy (data + 56, psargs, 80); + DIAGNOSTIC_POP; return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type, &data, sizeof (data)); } diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c index af37f828d5..3ea8dadf6d 100644 --- a/bfd/elfxx-aarch64.c +++ b/bfd/elfxx-aarch64.c @@ -640,7 +640,16 @@ _bfd_aarch64_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_ty va_start (ap, note_type); memset (data, 0, sizeof (data)); strncpy (data + 40, va_arg (ap, const char *), 16); + DIAGNOSTIC_PUSH; + /* GCC 8.1 warns about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ +#if GCC_VERSION == 8001 + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; +#endif strncpy (data + 56, va_arg (ap, const char *), 80); + DIAGNOSTIC_POP; va_end (ap); return elfcore_write_note (abfd, buf, bufsiz, "CORE", diff --git a/include/diagnostics.h b/include/diagnostics.h index f7412d4a38..4a674106dc 100644 --- a/include/diagnostics.h +++ b/include/diagnostics.h @@ -48,10 +48,8 @@ # define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \ DIAGNOSTIC_IGNORE ("-Wunused-function") -# if __GNUC__ == 8 && __GNUC_MINOR__ < 2 -# define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \ +# define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \ DIAGNOSTIC_IGNORE ("-Wstringop-truncation") -# endif #endif #ifndef DIAGNOSTIC_IGNORE_SELF_MOVE -- 2.17.1