From 222db5e3bb589a2b9b0dc0e49eecfef041473a4e Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 1 Aug 2001 16:10:42 +0000 Subject: [PATCH] Return zero only as the last step of qsort function. --- bfd/ChangeLog | 4 ++++ bfd/elf.c | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index f451dde616..71208e52c6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,7 @@ +2001-08-01 Adam Nemet + + * elf.c (elf_sort_sections): Return zero only as the last step. + 2001-08-01 Nick Clifton * config.bfd (arm-vxworks): Change name of define from VXWORKS to diff --git a/bfd/elf.c b/bfd/elf.c index 4e2d7ae8d9..8dc2f31454 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -2677,18 +2677,22 @@ elf_sort_sections (arg1, arg2) if (TOEND (sec1)) { if (TOEND (sec2)) - return sec1->target_index - sec2->target_index; + { + /* If the indicies are the same, do not return 0 + here, but continue to try the next comparison. */ + if (sec1->target_index - sec2->target_index != 0) + return sec1->target_index - sec2->target_index; + } else return 1; } - - if (TOEND (sec2)) + else if (TOEND (sec2)) return -1; #undef TOEND - /* Sort by size, to put zero sized sections before others at the - same address. */ + /* Sort by size, to put zero sized sections + before others at the same address. */ if (sec1->_raw_size < sec2->_raw_size) return -1; -- 2.11.0