[PATCH][bfd, opcodes] Remove C99 constructs

Tom de Vries tdevries@suse.de
Thu Sep 23 20:39:35 GMT 2021


Hi,

When doing a gdb build with --enable-targets=all and gcc-4.8, we run into
build errors.

Two of those are in bfd and opcodes, related to using for loop initial
declarations.  This is a C99 construct which is not availabe by default with
gcc-4.8.

Fix this by rewriting into regular for loops.

Build on x86_64-linux.

OK for trunk?

Thanks,
- Tom

[bfd, opcodes] Remove C99 constructs

---
 bfd/elf32-or1k.c  | 5 +++--
 opcodes/ppc-dis.c | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
index 4f9092539f5..c1690d1aaf7 100644
--- a/bfd/elf32-or1k.c
+++ b/bfd/elf32-or1k.c
@@ -2258,7 +2258,8 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
   unsigned output_insns[PLT_MAX_INSN_COUNT];
 
   /* Copy instructions into the output buffer.  */
-  for (size_t i = 0; i < insn_count; i++)
+  size_t i;
+  for (i = 0; i < insn_count; i++)
     output_insns[i] = insns[i];
 
   /* Honor the no-delay-slot setting.  */
@@ -2289,7 +2290,7 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
     }
 
   /* Write out the output buffer.  */
-  for (size_t i = 0; i < (insn_count+1); i++)
+  for (i = 0; i < (insn_count+1); i++)
     bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
 }
 
diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c
index f25909d1c01..aa455b407ac 100644
--- a/opcodes/ppc-dis.c
+++ b/opcodes/ppc-dis.c
@@ -1056,7 +1056,8 @@ print_insn_powerpc (bfd_vma memaddr,
 	      && ((insn & ((-1ULL << 50) | (0x3fULL << 26)))
 		  == ((1ULL << 58) | (1ULL << 52) | (57ULL << 26)) /* pld */))
 	    {
-	      for (int i = 0; i < 2; i++)
+	      int i;
+	      for (i = 0; i < 2; i++)
 		if (print_got_plt (private_data (info)->special + i, d34, info))
 		  break;
 	    }


More information about the Binutils mailing list