[RFA] Don't sort PT_NOTE sections.
Michael Snyder
msnyder@cygnus.com
Tue Dec 18 13:41:00 GMT 2001
Alan Modra wrote:
>
> On Wed, Dec 12, 2001 at 01:17:15PM -0800, Michael Snyder wrote:
> >
> > asection **secpp;
> >
> > /* If elf_segment_map is not from map_sections_to_segments, the
> > ! sections may not be correctly ordered. NOTE: do not sort
> > ! sections of type PT_NOTE. */
> > ! if (m->count > 1 && m->p_type != PT_NOTE)
> > qsort (m->sections, (size_t) m->count, sizeof (asection *),
> > elf_sort_sections);
>
> Your comment change adds no information not immediately obvious in the
> code.
Well, I always think more info is better than less.
But I'll see if I can make it more informative.
> Also, I think it may be safer to restrict this change to core
> files. ie. do sort for elf_elfheader (abfd)->e_type != ET_CORE
Yes, thank you, that is the test that I was looking for.
Revised patch attached:
-------------- next part --------------
2001-12-12 Michael Snyder <msnyder@redhat.com>
* elf.c (assign_file_positions_for_segments): Don't sort PT_NOTE
sections of corefiles. Also it makes no sense to sort if count == 1.
Index: elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.110
diff -c -3 -p -r1.110 elf.c
*** elf.c 2001/12/07 12:32:42 1.110
--- elf.c 2001/12/18 21:29:26
*************** assign_file_positions_for_segments (abfd
*** 3181,3188 ****
asection **secpp;
/* If elf_segment_map is not from map_sections_to_segments, the
! sections may not be correctly ordered. */
! if (m->count > 0)
qsort (m->sections, (size_t) m->count, sizeof (asection *),
elf_sort_sections);
--- 3181,3193 ----
asection **secpp;
/* If elf_segment_map is not from map_sections_to_segments, the
! sections may not be correctly ordered. NOTE: sorting should
! not be done to the PT_NOTE section of a corefile, which may
! contain several pseudo-sections artificially created by bfd.
! Sorting these pseudo-sections breaks things badly. */
! if (m->count > 1
! && !(elf_elfheader (abfd)->e_type == ET_CORE
! && m->p_type == PT_NOTE))
qsort (m->sections, (size_t) m->count, sizeof (asection *),
elf_sort_sections);
More information about the Binutils
mailing list