This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Committed, MMIX: Don't use addresses of items to stabilize qsortorder.
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: <binutils at sources dot redhat dot com>
- Date: Sun, 16 Jun 2002 16:50:03 -0400 (EDT)
- Subject: Committed, MMIX: Don't use addresses of items to stabilize qsortorder.
Doh! This bug caused almost all MMIX linking (including the ld
test "S-records with constructors") to fail on FreeBSD (and
probably most *BSD): ld got stuck in a loop since the sorted
array of global register relocs changed for every relaxation
round. Tested with no regressions, but I spotted several gas
and ld test-suite failures that I'll have to check; section
alignment and padding seems to have changed some time ago.
* elf64-mmix.c (bpo_reloc_request_sort_fn): Use member
bpo_reloc_no to break sort order ties, not address of items.
Index: elf64-mmix.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-mmix.c,v
retrieving revision 1.14
diff -p -c -r1.14 elf64-mmix.c
*** elf64-mmix.c 6 Jun 2002 00:29:21 -0000 1.14
--- elf64-mmix.c 16 Jun 2002 18:06:29 -0000
*************** bpo_reloc_request_sort_fn (p1, p2)
*** 2226,2233 ****
if (r1->value != r2->value)
return r1->value > r2->value ? 1 : -1;
! /* As a last re-sort, use the address so we get a stable sort. */
! return r1 > r2 ? 1 : (r1 < r2 ? -1 : 0);
}
/* For debug use only. Dumps the global register allocations resulting
--- 2226,2237 ----
if (r1->value != r2->value)
return r1->value > r2->value ? 1 : -1;
! /* As a last re-sort, use the relocation number, so we get a stable
! sort. The *addresses* aren't stable since items are swapped during
! sorting. It depends on the qsort implementation if this actually
! happens. */
! return r1->bpo_reloc_no > r2->bpo_reloc_no
! ? 1 : (r1->bpo_reloc_no < r2->bpo_reloc_no ? -1 : 0);
}
/* For debug use only. Dumps the global register allocations resulting
brgds, H-P