diff options
author | Alan Modra <amodra@gmail.com> | 2019-10-14 13:57:01 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-10-14 16:47:13 +1030 |
commit | 3d9ee7d24be691e8b89cb5ebf0db744be279d8db (patch) | |
tree | 147e7737f9ad5aece81d86128dd57becec88730d /ld/ldctor.h | |
parent | 08dec09d8a26c115921b17110da1e07cb233c494 (diff) | |
download | gdb-3d9ee7d24be691e8b89cb5ebf0db744be279d8db.zip gdb-3d9ee7d24be691e8b89cb5ebf0db744be279d8db.tar.gz gdb-3d9ee7d24be691e8b89cb5ebf0db744be279d8db.tar.bz2 |
qsort: ldctor.c CONSTRUCTORS
ctor_cmp had an ineffective comparison of addresses in an attempt to
ensure sort stability. Comparing the addresses passed to the
comparison function can't work since those addresses may be from an
array that is already perturbed by qsort.
* ldctor.h (struct set_element): Make next field a union, adding
idx field.
* ldctor.c (ctor_cmp): Dereference pointer and lose unnecessary
const. Replace final sort on pointer value with final sort on idx.
(ldctor_add_set_entry): Adjust next field access.
(ldctor_build_sets): Likewise. Set u.idx field for sort.
Diffstat (limited to 'ld/ldctor.h')
-rw-r--r-- | ld/ldctor.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ld/ldctor.h b/ld/ldctor.h index fa21277..b48a0db 100644 --- a/ld/ldctor.h +++ b/ld/ldctor.h @@ -40,7 +40,10 @@ struct set_info { }; struct set_element { - struct set_element *next; /* Next element. */ + union { + struct set_element *next; /* Next element. */ + long idx; + } u; const char *name; /* Name in set (may be NULL). */ asection *section; /* Section of value in set. */ bfd_vma value; /* Value in set. */ |