[PATCH] Fix segfault when .plt section does not exist
Maciej W. Rozycki
macro@imgtec.com
Tue Jan 24 22:06:00 GMT 2017
On Tue, 24 Jan 2017, Palmer Dabbelt wrote:
> diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
> index 320d318..a82b564 100644
> --- a/bfd/elfnn-riscv.c
> +++ b/bfd/elfnn-riscv.c
> @@ -2504,8 +2504,9 @@ riscv_elf_finish_dynamic_sections (bfd *output_bfd,
> 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;
> + if (elf_section_data (splt->output_section) != NULL)
> + elf_section_data (splt->output_section)->this_hdr.sh_entsize
> + = PLT_ENTRY_SIZE;
FWIW the check for a discarded output section is usually written like:
if (!bfd_is_abs_section (splt->output_section))
(and you might want to skip the entire PLT fill code in that case).
Maciej
More information about the Binutils
mailing list