This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH, COMMITTED]: Fix seg fault in elf32.em:_after_open
- From: Pedro Alves <pedro at codesourcery dot com>
- To: binutils at sourceware dot org
- Cc: Nick Clifton <nickc at redhat dot com>
- Date: Fri, 20 Aug 2010 16:16:49 +0100
- Subject: Re: [PATCH, COMMITTED]: Fix seg fault in elf32.em:_after_open
- References: <m3lj815nxt.fsf@redhat.com>
On Friday 20 August 2010 16:00:30, Nick Clifton wrote:
> Whilst working on another bug I came across a seg-fault in the
> _after_open() function in elf32.em. If the target is not an ELF
> binary then get_elf_backend_data will return NULL, but the code was
> not checking for this. Fixed by applying the following patch.
(...)
> bed = get_elf_backend_data (abfd);
> ! if (bed == NULL)
> ! s = NULL;
> ! else
> ! s = bfd_make_section_with_flags (abfd, ".eh_frame_hdr",
> ! bed->dynamic_sec_flags
> ! | SEC_READONLY);
Is it valid to call get_elf_backend_data on a non-elf bfd at all?
#define get_elf_backend_data(abfd) \
xvec_get_elf_backend_data ((abfd)->xvec)
#define bfd_mach_o_get_backend_data(abfd) \
((bfd_mach_o_backend_data*)(abfd)->xvec->backend_data)
.#define coff_backend_info(abfd) \
. ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
It appears that for other flavours, it may happen to return
something undefined.
Shouldn't that check be something like
bfd_get_flavour (abfd) != bfd_target_elf_flavour instead?
--
Pedro Alves