This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 0/2] LD/testsuite: run_dump_test: Bring in line with its binutils and GAS counterparts


On Thu, Jul 05, 2018 at 09:16:16PM +0100, Maciej W. Rozycki wrote:
> Hi,
> 
>  This small patch series means to bring the test status reporting in the 
> LD implementation of `run_dump_test' in line with its binutils and GAS 
> counterparts.  See individual change descriptions for details.
> 
>  No regressions across my usual test targets, OK to apply?

They both look good to me.

>  NB all `aarch64', `arm', `powerpc*'/`ppc' and `s390*' targets currently 
> fail building with GCC 4.4 and therefore were not tested.  The build error 
> is the same across all these targets, although in different source files:
> 
> .../bfd/elfxx-aarch64.c: In function '_bfd_aarch64_elf_write_core_note':
> .../bfd/elfxx-aarch64.c:643: error: #pragma GCC diagnostic not allowed inside functions
> .../bfd/elfxx-aarch64.c:652: error: #pragma GCC diagnostic not allowed inside functions
> 
> .../bfd/elf32-arm.c: In function 'elf32_arm_nabi_write_core_note':
> .../bfd/elf32-arm.c:2177: error: #pragma GCC diagnostic not allowed inside functions
> .../bfd/elf32-arm.c:2186: error: #pragma GCC diagnostic not allowed inside functions
> 
> .../bfd/elf32-ppc.c: In function 'ppc_elf_write_core_note':
> .../bfd/elf32-ppc.c:2414: error: #pragma GCC diagnostic not allowed inside functions
> .../bfd/elf32-ppc.c:2423: error: #pragma GCC diagnostic not allowed inside functions
> 
> .../bfd/elf64-ppc.c: In function 'ppc64_elf_write_core_note':
> .../bfd/elf64-ppc.c:3044: error: #pragma GCC diagnostic not allowed inside functions
> .../bfd/elf64-ppc.c:3053: error: #pragma GCC diagnostic not allowed inside functions
> 
> .../bfd/elf32-s390.c: In function 'elf_s390_write_core_note':
> .../bfd/elf32-s390.c:3954: error: #pragma GCC diagnostic not allowed inside functions
> .../bfd/elf32-s390.c:3963: error: #pragma GCC diagnostic not allowed inside functions
> 
> .../bfd/elf64-s390.c: In function 'elf_s390_write_core_note':
> .../bfd/elf64-s390.c:3763: error: #pragma GCC diagnostic not allowed inside functions
> .../bfd/elf64-s390.c:3772: error: #pragma GCC diagnostic not allowed inside functions

Ha, so we've exchanged a warning on one version of gcc for an error
on another.  Fixed as follows.

include/
	* diagnostics.h: Comment on macro usage.
bfd/
	* elf32-arm.c (elf32_arm_nabi_write_core_note): Don't use
	DIAGNOTIC_PUSH and DIAGNOSTIC_POP unconditionally.
	* elf32-ppc.c (ppc_elf_write_core_note): Likewise.
	* elf32-s390.c (elf_s390_write_core_note): Likewise.
	* elf64-ppc.c (ppc64_elf_write_core_note): Likewise.
	* elf64-s390.c (elf_s390_write_core_note): Likewise.
	* elfxx-aarch64.c (_bfd_aarch64_elf_write_core_note): Likewise.

diff --git a/include/diagnostics.h b/include/diagnostics.h
index 34fc01b85b..9e9d1a832f 100644
--- a/include/diagnostics.h
+++ b/include/diagnostics.h
@@ -16,6 +16,20 @@
 #ifndef DIAGNOSTICS_H
 #define DIAGNOSTICS_H
 
+/* If at all possible, fix the source rather than using these macros
+   to silence warnings.  If you do use these macros be aware that
+   you'll need to condition their use on particular compiler versions,
+   which can be done for gcc using ansidecl.h's GCC_VERSION macro.
+
+   gcc versions between 4.2 and 4.6 do not allow pragma control of
+   diagnostics inside functions, giving a hard error if you try to use
+   the finer control available with later versions.
+   gcc prior to 4.2 warns about diagnostic push and pop.
+
+   The other macros have restrictions too, for example gcc-5, gcc-6
+   and gcc-7 warn that -Wstringop-truncation is unknown, unless you
+   also add DIAGNOSTIC_IGNORE ("-Wpragma").  */
+
 #ifdef __GNUC__
 # define DIAGNOSTIC_PUSH _Pragma ("GCC diagnostic push")
 # define DIAGNOSTIC_POP _Pragma ("GCC diagnostic pop")
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index b21901c0f5..9c611813c6 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2174,16 +2174,18 @@ 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);
+#if GCC_VERSION == 8001
 	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);
+#if GCC_VERSION == 8001
 	DIAGNOSTIC_POP;
+#endif
 	va_end (ap);
 
 	return elfcore_write_note (abfd, buf, bufsiz,
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 3024674007..5e9251bdb9 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -2411,16 +2411,18 @@ 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);
+#if GCC_VERSION == 8001
 	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);
+#if GCC_VERSION == 8001
 	DIAGNOSTIC_POP;
+#endif
 	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 ebda1dacdc..56008a13eb 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -3951,16 +3951,18 @@ elf_s390_write_core_note (bfd *abfd, char *buf, int *bufsiz,
 	va_end (ap);
 
 	strncpy (data + 28, fname, 16);
+#if GCC_VERSION == 8001
 	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);
+#if GCC_VERSION == 8001
 	DIAGNOSTIC_POP;
+#endif
 	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 b780f1ab13..45d81777eb 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -3041,16 +3041,18 @@ 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);
+#if GCC_VERSION == 8001
 	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);
+#if GCC_VERSION == 8001
 	DIAGNOSTIC_POP;
+#endif
 	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 93a3c7c22a..ea10a89266 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -3760,16 +3760,18 @@ elf_s390_write_core_note (bfd *abfd, char *buf, int *bufsiz,
 	va_end (ap);
 
 	strncpy (data + 40, fname, 16);
+#if GCC_VERSION == 8001
 	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);
+#if GCC_VERSION == 8001
 	DIAGNOSTIC_POP;
+#endif
 	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 61a5ffb8a8..af02f2e48e 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -640,16 +640,18 @@ _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);
+#if GCC_VERSION == 8001
 	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);
+#if GCC_VERSION == 8001
 	DIAGNOSTIC_POP;
+#endif
 	va_end (ap);
 
 	return elfcore_write_note (abfd, buf, bufsiz, "CORE",

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]