This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Fix segfault when .plt section does not exist
- From: "Maciej W. Rozycki" <macro at imgtec dot com>
- To: Palmer Dabbelt <palmer at dabbelt dot com>
- Cc: <binutils at sourceware dot org>, Andrew Waterman <andrew at sifive dot com>
- Date: Tue, 24 Jan 2017 22:05:47 +0000
- Subject: Re: [PATCH] Fix segfault when .plt section does not exist
- Authentication-results: sourceware.org; auth=none
- References: <20170124203435.20490-1-palmer@dabbelt.com> <20170124203435.20490-2-palmer@dabbelt.com>
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