[binutils-gdb/binutils-2_47-branch] readelf.c gcc-4.9 compile error

Alan Modra via Binutils-cvs <[email protected]> Thu, 16 Jul 2026 00:18:38 +0000 (GMT)
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e95dd678ac5a31dd8a2aaf42036b7f3df4c28056

commit e95dd678ac5a31dd8a2aaf42036b7f3df4c28056
Author: Alan Modra <[email protected]>
Date:   Thu Jul 16 07:27:58 2026 +0930

    readelf.c gcc-4.9 compile error
    
    gcc-4.9 doesn't like an empty initialiser.
    
    binutils/readelf.c: In function ‘process_relocs’:
    binutils/readelf.c:10229:5: error: missing initializer for field ‘sh_name’ of ‘Elf_Internal_Shdr’ [-Werror=missing-field-initializers]
         Elf_Internal_Shdr section = {};
    
            * readelf.c (process_relocs): Avoid gcc-4.9 compile error.
    
    (cherry picked from commit 4643afba9100939b16f50e13f085fc5bd0284930)

Diff:
---
 binutils/readelf.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 8b6ebf526df..1f7a90e7ee3 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -10231,12 +10231,12 @@ process_relocs (Filedata * filedata)
 		     is passed to readelf.  */
 		  uint64_t num_reloc;
 		  uint64_t *relrs = NULL;
-		  Elf_Internal_Shdr section = {};
-		  section.sh_offset
-		    = filedata->dynamic_info[DT_RELR];
-		  section.sh_size = rel_size;
-		  section.sh_entsize = rel_entsz;
-		  section.sh_type = SHT_RELR;
+		  Elf_Internal_Shdr section = {
+		    .sh_type = SHT_RELR,
+		    .sh_offset = filedata->dynamic_info[DT_RELR],
+		    .sh_size = rel_size,
+		    .sh_entsize = rel_entsz
+		  };
 		  validate_section_info (&section, NULL, 0, filedata);
 		  num_reloc = count_relr_relocations (filedata,
 						      &section,