From patchwork Mon May 21 12:15:57 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: 27355 Received: (qmail 60400 invoked by alias); 21 May 2018 12:16:22 -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 60223 invoked by uid 89); 21 May 2018 12:16:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KAM_SHORT, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=bfdinh, bfd-in.h, UD:bfd-in.h X-Spam-User: qpsmtpd, 2 recipients X-HELO: mga01.intel.com Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 May 2018 12:16:17 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2018 05:15:58 -0700 X-ExtLoop1: 1 Received: from gnu-cfl-1.sc.intel.com ([172.25.70.237]) by orsmga006.jf.intel.com with ESMTP; 21 May 2018 05:15:57 -0700 From: "H.J. Lu" To: binutils@sourceware.org Cc: gdb-patches@sourceware.org Subject: [PATCH 3/3] Use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION to silence GCC 8 Date: Mon, 21 May 2018 05:15:57 -0700 Message-Id: <20180521121557.16535-3-hjl.tools@gmail.com> In-Reply-To: <20180521121557.16535-1-hjl.tools@gmail.com> References: <20180521121557.16535-1-hjl.tools@gmail.com> X-IsSubscribed: yes GCC 8 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. 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. --- bfd/bfd-in.h | 1 + bfd/bfd-in2.h | 1 + bfd/elf32-arm.c | 7 +++++++ bfd/elf32-ppc.c | 7 +++++++ bfd/elf32-s390.c | 7 +++++++ bfd/elf64-ppc.c | 7 +++++++ bfd/elf64-s390.c | 7 +++++++ bfd/elfxx-aarch64.c | 7 +++++++ 8 files changed, 44 insertions(+) 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 c64eee1fe1..4a5c51fdf8 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 5a3b58ff0d..4e04a2f699 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -2174,7 +2174,14 @@ 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 warns about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; 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 462c8af311..b5cb14ecbf 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -2411,7 +2411,14 @@ 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 warns about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; 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 b3603bd865..b9e1602aa2 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -3951,7 +3951,14 @@ elf_s390_write_core_note (bfd *abfd, char *buf, int *bufsiz, va_end (ap); strncpy (data + 28, fname, 16); + DIAGNOSTIC_PUSH; + /* GCC 8 warns about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; 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 b166558945..bf314b3571 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -3041,7 +3041,14 @@ 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 warns about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; 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 bfa02340ca..4552bd6ee8 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -3760,7 +3760,14 @@ elf_s390_write_core_note (bfd *abfd, char *buf, int *bufsiz, va_end (ap); strncpy (data + 40, fname, 16); + DIAGNOSTIC_PUSH; + /* GCC 8 warns about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; 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 45a732db2b..f418581048 100644 --- a/bfd/elfxx-aarch64.c +++ b/bfd/elfxx-aarch64.c @@ -659,7 +659,14 @@ _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 warns about 80 equals destination size with + -Wstringop-truncation: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643 + */ + DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION; strncpy (data + 56, va_arg (ap, const char *), 80); + DIAGNOSTIC_POP; va_end (ap); return elfcore_write_note (abfd, buf, bufsiz, "CORE",