* PR 21266, unstable qsort in bfd/elf64-ppc.c
@ 2017-03-19 23:59 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2017-03-19 23:59 UTC (permalink / raw)
To: binutils
Classic fix to unstable qsort, when sorting pointers. Note that there
is a dereference of the qsort comparison function parameters earlier
in compare_symbols, so this isn't making the mistake of trying to
stabilize by looking at the address of memory that qsort is shuffling.
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 5dea352..50e76c2 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2017-03-20 Alan Modra <amodra@gmail.com>
+
+ PR 21266
+ * elf64-ppc.c (compare_symbols): Stabilize sort.
+
2017-03-18 Alan Modra <amodra@gmail.com>
* elf64-ppc.c (struct ppc_link_hash_table): Add
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 1193c1f..ae39032 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -3188,7 +3188,7 @@ compare_symbols (const void *ap, const void *bp)
if ((a->flags & BSF_DYNAMIC) == 0 && (b->flags & BSF_DYNAMIC) != 0)
return 1;
- return 0;
+ return a > b;
}
/* Search SYMS for a symbol of the given VALUE. */
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-03-19 23:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-19 23:59 PR 21266, unstable qsort in bfd/elf64-ppc.c Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).