qsort: pe-dll.c reloc sorting
authorAlan Modra <amodra@gmail.com>
Mon, 14 Oct 2019 03:25:32 +0000 (13:55 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 14 Oct 2019 06:17:13 +0000 (16:47 +1030)
* pe-dll.c (reloc_data_type): Add idx field.
(reloc_sort): Perform final sort by idx.
(generate_reloc): Set idx.

ld/ChangeLog
ld/pe-dll.c

index 06c7cf761ea40ab852e9f274002f311492112928..19ed0b5f21c1c5435ff36859bce6d8fed3ead0cf 100644 (file)
@@ -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.
index 6daf984b0f7ba5ded9adc789e5cbab0201d7a8b0..4679fca6d52c91f973bd011a5634559f98655d46 100644 (file)
@@ -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)
 
This page took 0.029646 seconds and 4 git commands to generate.