From: "H.J. Lu" <hjl.tools@gmail.com>
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 13:12:00 -0000 [thread overview]
Message-ID: <20180521121557.16535-3-hjl.tools@gmail.com> (raw)
In-Reply-To: <20180521121557.16535-1-hjl.tools@gmail.com>
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 <stdarg.h>
#include <sys/stat.h>
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 <stdarg.h>
#include <sys/stat.h>
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",
--
2.17.0
next prev parent reply other threads:[~2018-05-21 12:16 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-21 12:16 [PATCH 1/3] Move gdb/common/diagnostics.h to include/diagnostics.h H.J. Lu
2018-05-21 13:10 ` [PATCH 2/3] Add DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION H.J. Lu
2018-06-01 7:57 ` Nick Clifton
[not found] ` <20180601101949.GA7660@bubble.grove.modra.org>
2018-06-01 16:51 ` H.J. Lu
2018-06-04 12:13 ` Nick Clifton
2018-06-04 12:19 ` Pedro Alves
2018-06-04 12:46 ` H.J. Lu
[not found] ` <CAMe9rOox6mZ6MX=GyC7-XJ2GuDzc5cjrLDyc3Hei5gBR4fWw7w@mail.gmail.com>
2018-06-04 13:40 ` Pedro Alves
2018-06-04 14:04 ` Pedro Alves
2018-05-21 13:12 ` H.J. Lu [this message]
2018-06-01 7:59 ` [PATCH 3/3] Use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION to silence GCC 8 Nick Clifton
2018-06-04 16:58 ` H.J. Lu
2018-06-04 17:06 ` Pedro Alves
2018-07-02 16:25 ` Tulio Magno Quites Machado Filho
2018-05-21 14:12 ` [PATCH 1/3] Move gdb/common/diagnostics.h to include/diagnostics.h Simon Marchi
2018-06-01 7:49 ` Nick Clifton
[not found] ` <B781F464-751E-4D45-8881-36F6003759BE@glasgow.ac.uk>
2018-06-04 13:12 ` H.J. Lu
2018-06-04 13:24 ` John Marshall
2018-06-04 13:35 ` Pedro Alves
2018-06-04 13:37 ` H.J. Lu
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=20180521121557.16535-3-hjl.tools@gmail.com \
--to=hjl.tools@gmail.com \
--cc=binutils@sourceware.org \
--cc=gdb-patches@sourceware.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: link
Be 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