summaryrefslogtreecommitdiffstats
path: root/libdwfl/derelocate.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdwfl/derelocate.c')
-rw-r--r--libdwfl/derelocate.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/libdwfl/derelocate.c b/libdwfl/derelocate.c
index 8d965af9..2f80b20f 100644
--- a/libdwfl/derelocate.c
+++ b/libdwfl/derelocate.c
@@ -57,22 +57,23 @@ struct secref
static int
compare_secrefs (const void *a, const void *b)
{
- struct secref const *p1 = *(struct secref *const *)a;
- struct secref const *p2 = *(struct secref *const *)b;
+ struct secref *const *p1 = a;
+ struct secref *const *p2 = b;
/* No signed difference calculation is correct here, since the
terms are unsigned and could be more than INT64_MAX apart. */
- if (p1->start < p2->start)
+ if ((*p1)->start < (*p2)->start)
return -1;
- if (p1->start > p2->start)
+ if ((*p1)->start > (*p2)->start)
return 1;
- if (p1->end < p2->end)
+
+ if ((*p1)->end < (*p2)->end)
return -1;
- if (p1->end > p2->end)
+ if ((*p1)->end > (*p2)->end)
return 1;
- if (p1->name == NULL)
- return p2->name == NULL ? 0 : -1;
- return p2->name == NULL ? 1 : strcmp(p1->name, p2->name);
+
+ /* Same start/end, then just compare which section came first. */
+ return elf_ndxscn ((*p1)->scn) - elf_ndxscn ((*p2)->scn);
}
static int