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

Re: [PATCH] Fix segfault when .plt section does not exist


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


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