Use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION to silence GCC 8.1
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 4 Jun 2018 17:01:34 +0000 (10:01 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 4 Jun 2018 17:01:46 +0000 (10:01 -0700)
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/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/elf32-arm.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf64-ppc.c
bfd/elf64-s390.c
bfd/elfxx-aarch64.c
include/ChangeLog
include/diagnostics.h

index a8f4688005651674b9e826253c6467fdd134fe3b..b36cdabef9e09fd835437f21aba29be5aaa311a7 100644 (file)
@@ -1,3 +1,18 @@
+2018-06-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       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.
+
 2018-06-03  Jim Wilson  <jimw@sifive.com>
 
        PR ld/23244
index 481587e458f1ce8f1d5164f114a5a22009ac295d..1d477c3f5f2d1bb4c3791abf1ed3ccb9a841879b 100644 (file)
@@ -34,6 +34,7 @@ extern "C" {
 
 #include "ansidecl.h"
 #include "symcat.h"
+#include "diagnostics.h"
 #include <stdarg.h>
 #include <sys/stat.h>
 
index ef62f319534249637cf43e03352f7a00df8fa941..65735f026e6bfcf10f18bc756f022cb9abf7ff87 100644 (file)
@@ -41,6 +41,7 @@ extern "C" {
 
 #include "ansidecl.h"
 #include "symcat.h"
+#include "diagnostics.h"
 #include <stdarg.h>
 #include <sys/stat.h>
 
index dbfd838fbe09eaceb905fcaa6b7416fc5c83cbad..870111b5ed2ea1f5e3b1cad28106e7306f2c1624 100644 (file)
@@ -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,
index 3482baca2051dbb98f42de21d5369655133a2661..ea8dbed9819d8dcb461091e6d00becc07fa320f6 100644 (file)
@@ -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));
index 99ceb76d3d1fab42a4ff05fc5fd4eb3a7844504c..ebda1dacdcc15fced8e4b0839e8a5b2ad2f9f94c 100644 (file)
@@ -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));
       }
index f543cb02887237c9ba18305cdf893bbc408c930d..16199fbe3ed4295affbd9aafa2e15f0ce9086be7 100644 (file)
@@ -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));
index 612557fa74ff300307200a51c1ff940d5947151c..93a3c7c22aca63b747a5ca596d1096d1dc2a5c72 100644 (file)
@@ -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));
       }
index af37f828d54199ecbd38ee718932d5f147c7d00c..3ea8dadf6d94fa74777b4d26a06d5effcca99a81 100644 (file)
@@ -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",
index 74be7787dc66230a7c4296bff6ed56c868e183a7..76a312a0ddd29babea1fb5cf740fb025749c2876 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * diagnostics.h (DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION): Always
+       define for GCC.
+
 2018-06-04  H.J. Lu  <hongjiu.lu@intel.com>
 
        * diagnostics.h (DIAGNOSTIC_STRINGIFY_1): New.
index f7412d4a38ffcdfa94a65a524dd591cc05037433..4a674106dc01905719f3a757e6546bef5f4969d4 100644 (file)
 # 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
This page took 0.042208 seconds and 4 git commands to generate.