This is the mail archive of the binutils-cvs@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]

[binutils-gdb] RISC-V/BFD: Correct a missing initializer error with pre-4.7 GCC


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e65b1a78686f840ab46fe97355d674919185adc8

commit e65b1a78686f840ab46fe97355d674919185adc8
Author: Maciej W. Rozycki <macro@mips.com>
Date:   Mon Feb 5 14:05:51 2018 +0000

    RISC-V/BFD: Correct a missing initializer error with pre-4.7 GCC
    
    Correct a commit 9d06997adb88 ("RISC-V: Relax RISCV_PCREL_* to
    RISCV_GPREL_*") regression and remove a `-Wmissing-field-initializers'
    compilation error:
    
    cc1: warnings being treated as errors
    .../bfd/elfnn-riscv.c: In function '_bfd_riscv_relax_pc':
    .../bfd/elfnn-riscv.c:3117: error: missing initializer
    .../bfd/elfnn-riscv.c:3117: error: (near initialization for 'hi_reloc.hi_addend')
    make[4]: *** [elf64-riscv.lo] Error 1
    
    which for versions of GCC before 4.7 prevents support for RISC-V targets
    from being built.  See also GCC PR c/36750.
    
    	bfd/
    	* elfnn-riscv.c (_bfd_riscv_relax_pc): Use `memset' to
    	initialize `hi_reloc'.

Diff:
---
 bfd/ChangeLog     | 5 +++++
 bfd/elfnn-riscv.c | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9a8a320..ecd1c7b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,10 @@
 2018-02-05  Maciej W. Rozycki  <macro@mips.com>
 
+	* elfnn-riscv.c (_bfd_riscv_relax_pc): Use `memset' to
+	initialize `hi_reloc'.
+
+2018-02-05  Maciej W. Rozycki  <macro@mips.com>
+
 	* elfxx-mips.c (_bfd_mips_elf_section_processing): For
 	SHT_MIPS_REGINFO sections don't assert the correct size and
 	report an error instead.
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index f2136b2..3524fed 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -3143,7 +3143,8 @@ _bfd_riscv_relax_pc  (bfd *abfd,
 
   /* Chain the _LO relocs to their cooresponding _HI reloc to compute the
    * actual target address.  */
-  riscv_pcgp_hi_reloc hi_reloc = {0};
+  riscv_pcgp_hi_reloc hi_reloc;
+  memset (&hi_reloc, 0, sizeof (hi_reloc));
   switch (ELFNN_R_TYPE (rel->r_info))
     {
     case R_RISCV_PCREL_LO12_I:


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