RISC-V/BFD: Correct a missing initializer error with pre-4.7 GCC
authorMaciej W. Rozycki <macro@mips.com>
Mon, 5 Feb 2018 14:05:51 +0000 (14:05 +0000)
committerMaciej W. Rozycki <macro@mips.com>
Mon, 5 Feb 2018 14:06:46 +0000 (14:06 +0000)
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'.

bfd/ChangeLog
bfd/elfnn-riscv.c

index 9a8a32010198945bb321a0512ffa2245d5ab9591..ecd1c7beea83356495bb6448cfb9eec195546bbf 100644 (file)
@@ -1,3 +1,8 @@
+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
index f2136b2f902161b83ef44dcfecc064249d2cda28..3524fede0f7ffdec982514766663616631598558 100644 (file)
@@ -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:
This page took 0.030138 seconds and 4 git commands to generate.