Fix segfault when .plt section does not exist
authorAndrew Waterman <andrew@sifive.com>
Mon, 23 Jan 2017 20:58:30 +0000 (12:58 -0800)
committerPalmer Dabbelt <palmer@dabbelt.com>
Wed, 8 Feb 2017 02:02:12 +0000 (18:02 -0800)
bfd/ChangeLog

2017-02-07  Andrew Waterman  <andrew@sifive.com>

* elfnn-riscv.c (riscv_elf_finish_dynamic_sections): Only write PLT
entry size if PLT header is written.

bfd/ChangeLog
bfd/elfnn-riscv.c

index 8d21e0401e7852f34d637bd0c1c7cb73333943b3..f21d6544c1c0f65f0bb5d54223a1bd991735d662 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-07  Andrew Waterman  <andrew@sifive.com>
+
+       * elfnn-riscv.c (riscv_elf_finish_dynamic_sections): Only write PLT
+       entry size if PLT header is written.
+
 2017-02-06  Sheldon Lobo  <sheldon.lobo@oracle.com>
 
        Fix sparc64 dynamic relocation processing to use the dynamic
index 320d318ce5b4f446d18f1ab845da0b1c987f1242..b8dd1f23aa6d7fb84fa653fd5433e8f572b819f2 100644 (file)
@@ -2502,10 +2502,10 @@ riscv_elf_finish_dynamic_sections (bfd *output_bfd,
 
          for (i = 0; i < PLT_HEADER_INSNS; i++)
            bfd_put_32 (output_bfd, plt_header[i], splt->contents + 4*i);
-       }
 
-      elf_section_data (splt->output_section)->this_hdr.sh_entsize
-       = PLT_ENTRY_SIZE;
+         elf_section_data (splt->output_section)->this_hdr.sh_entsize
+           = PLT_ENTRY_SIZE;
+       }
     }
 
   if (htab->elf.sgotplt)