This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Use stable sort for ld -r relocs
- From: Mike Frysinger <vapier at gentoo dot org>
- To: Alan Modra <amodra at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Wed, 26 Aug 2015 23:28:26 -0400
- Subject: Re: Use stable sort for ld -r relocs
- Authentication-results: sourceware.org; auth=none
- References: <20150826140258 dot GB24814 at bubble dot grove dot modra dot org> <20150826220441 dot GG3116 at vapier> <20150827012828 dot GE24814 at bubble dot grove dot modra dot org>
On 27 Aug 2015 10:58, Alan Modra wrote:
> On Wed, Aug 26, 2015 at 06:04:41PM -0400, Mike Frysinger wrote:
> > On 26 Aug 2015 23:32, Alan Modra wrote:
> > > A number of targets emit multiple relocs at a given r_offset, and
> > > depend on those relocs staying in their original order. qsort doesn't
> > > satisfy this requirement, although it appears from my non-rigorous
> > > testing that glibc's msort.c implementation may in fact be stable.
> > >
> > > I made the mistake of backporting my PR 17666 fix to 2.25.1, thinking
> > > the code had enough time to settle on mainline, but for anyone with a
> > > system libc that provides an unstable qsort this will mean 2.25.1
> > > ld -r may be broken on some targets.
> > >
> > > PR 18867
> > > * elflink.c (cmp_ext32l_r_offset, cmp_ext32b_r_offset): Delete.
> > > (cmp_ext64l_r_offset, cmp_ext64b_r_offset): Delete.
> > > (ext32l_r_offset, ext32b_r_offset, ext64l_r_offset, ext64b_r_offset):
> > > New functions.
> > > (elf_link_adjust_relocs): Use an insertion sort to sort relocs.
> >
> > were you planning on making another change ? i tested master
> > (1dc7a6235090327d7b5586f85e6115c3cd13ed83) and it still crashes
> > on alpha. this hack makes things work:
> > --- a/bfd/elflink.c
> > +++ b/bfd/elflink.c
> > ...
> > - sort = bed->sort_relocs_p == NULL || (*bed->sort_relocs_p) (o);
> > + sort = 0; //bed->sort_relocs_p == NULL || (*bed->sort_relocs_p) (o);
>
> Yes, I'm going to turn off reloc sorting on alpha.
thanks, that works. planning on putting both fixes into the 2.25 branch too ?
-mike