diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2017-04-20 16:54:26 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2017-05-03 00:28:08 +0200 |
commit | d7e1e08f68afd6c3363231e3100fa0124a2d5cb6 (patch) | |
tree | 1ab1a37a1bde59116b255cba07289c8ae4c98af4 /libdwfl | |
parent | e88787f9cd2af5be00aa6f53320cf85f7c08f1f2 (diff) |
Make elf section sorting more deterministic
At least one test (dwfl-addr-sect) depends on the order of elf sections
with equal addresses. This is not guaranteed by the code. Compare also
by end address and section index to tell entries apart.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdwfl')
-rw-r--r-- | libdwfl/ChangeLog | 6 | ||||
-rw-r--r-- | libdwfl/derelocate.c | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 859b2ff5..9bce6b1e 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,6 +1,12 @@ 2017-04-20 Ulf Hermann <ulf.hermann@qt.io> Mark Wielaard <mark@klomp.org> + * derelocate.c (compare_secrefs): Compare by end address and then by + section number if addresses are equal. + +2017-04-20 Ulf Hermann <ulf.hermann@qt.io> + Mark Wielaard <mark@klomp.org> + * linux-kernel-modules.c: Always return NULL from kernel_release() on non-linux systems and set errno to ENOTSUP. diff --git a/libdwfl/derelocate.c b/libdwfl/derelocate.c index e5c3e12e..2f80b20f 100644 --- a/libdwfl/derelocate.c +++ b/libdwfl/derelocate.c @@ -67,7 +67,13 @@ compare_secrefs (const void *a, const void *b) if ((*p1)->start > (*p2)->start) return 1; - return 0; + if ((*p1)->end < (*p2)->end) + return -1; + if ((*p1)->end > (*p2)->end) + return 1; + + /* Same start/end, then just compare which section came first. */ + return elf_ndxscn ((*p1)->scn) - elf_ndxscn ((*p2)->scn); } static int |