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, COMMITTED]: Fix seg fault in elf32.em:_after_open


On Fri, Aug 20, 2010 at 8:16 AM, Pedro Alves <pedro@codesourcery.com> wrote:
> 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?
>

I agree. The patch doesn't look right to me. Nick, if you can
provide a testcase, I will look into it.

Thanks.


-- 
H.J.


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