aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-10-14 13:55:32 +1030
committerAlan Modra <amodra@gmail.com>2019-10-14 16:47:13 +1030
commit08dec09d8a26c115921b17110da1e07cb233c494 (patch)
tree674e7d8a2814e0e4d511c5cc4d6ec8554b782701
parent6ce9ba7afcc64217e008d3b51f8c7ef4c496957e (diff)
downloadgdb-08dec09d8a26c115921b17110da1e07cb233c494.zip
gdb-08dec09d8a26c115921b17110da1e07cb233c494.tar.gz
gdb-08dec09d8a26c115921b17110da1e07cb233c494.tar.bz2
qsort: pe-dll.c reloc sorting
* pe-dll.c (reloc_data_type): Add idx field. (reloc_sort): Perform final sort by idx. (generate_reloc): Set idx.
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/pe-dll.c16
2 files changed, 19 insertions, 3 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 06c7cf7..19ed0b5 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2019-10-14 Alan Modra <amodra@gmail.com>
+
+ * pe-dll.c (reloc_data_type): Add idx field.
+ (reloc_sort): Perform final sort by idx.
+ (generate_reloc): Set idx.
+
2019-10-13 Nick Clifton <nickc@redhat.com>
* NEWS: Delete superflous "Changes in 2.33" comment.
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index 6daf984..4679fca 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -445,16 +445,25 @@ typedef struct
bfd_vma vma;
char type;
short extra;
+ int idx;
}
reloc_data_type;
static int
reloc_sort (const void *va, const void *vb)
{
- bfd_vma a = ((const reloc_data_type *) va)->vma;
- bfd_vma b = ((const reloc_data_type *) vb)->vma;
+ const reloc_data_type *a = (const reloc_data_type *) va;
+ const reloc_data_type *b = (const reloc_data_type *) vb;
- return (a > b) ? 1 : ((a < b) ? -1 : 0);
+ if (a->vma > b->vma)
+ return 1;
+ if (a->vma < b->vma)
+ return -1;
+ if (a->idx > b->idx)
+ return 1;
+ if (a->idx < b->idx)
+ return -1;
+ return 0;
}
static int
@@ -1596,6 +1605,7 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
}
reloc_data[total_relocs].vma = sec_vma + relocs[i]->address;
+ reloc_data[total_relocs].idx = total_relocs;
#define BITS_AND_SHIFT(bits, shift) (bits * 1000 | shift)