aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorSteve Chamberlain <sac@cygnus>1995-06-09 19:21:47 +0000
committerSteve Chamberlain <sac@cygnus>1995-06-09 19:21:47 +0000
commitd1ec549d7b021c9c1612f3bae4bf5478d3fed56c (patch)
tree804cb25631bea8e38ceb42f51e4ad5aafc2719d9 /bfd
parent3b1f83adadb508ac01e146dbc1d3f37eed55af6e (diff)
downloadgdb-d1ec549d7b021c9c1612f3bae4bf5478d3fed56c.zip
gdb-d1ec549d7b021c9c1612f3bae4bf5478d3fed56c.tar.gz
gdb-d1ec549d7b021c9c1612f3bae4bf5478d3fed56c.tar.bz2
* elfcode.h (elf_sort_hdrs): Rewrite to be symmetrical.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog4
-rw-r--r--bfd/elfcode.h28
2 files changed, 19 insertions, 13 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 45750f1..35ab786 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,7 @@
+Fri Jun 9 12:20:28 1995 Steve Chamberlain <sac@rtl.cygnus.com>
+
+ * elfcode.h (elf_sort_hdrs): Rewrite to be symmetrical.
+
Fri Jun 9 12:49:00 1995 Jeff Law (law@snake.cs.utah.edu)
* bfd-in.h: (TRUE_FALSE_ALREADY_DEFINED): Define this if
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 4155cde..63b55f4 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -2251,20 +2251,27 @@ assign_file_positions_except_relocs (abfd, dosyms)
/* Sort the ELF headers by VMA. We sort headers which are not
SHF_ALLOC to the end. */
+
static int
elf_sort_hdrs (arg1, arg2)
const PTR arg1;
const PTR arg2;
{
+ int ret;
const Elf_Internal_Shdr *hdr1 = *(const Elf_Internal_Shdr **) arg1;
const Elf_Internal_Shdr *hdr2 = *(const Elf_Internal_Shdr **) arg2;
- if ((hdr1->sh_flags & SHF_ALLOC) != 0)
- {
- int ret;
+#define TOEND(x) (((x)->sh_flags & SHF_ALLOC)==0)
- if ((hdr2->sh_flags & SHF_ALLOC) == 0)
+ if (TOEND(hdr1))
+ if (TOEND(hdr2))
+ return 0;
+ else
+ return 1;
+
+ if (TOEND(hdr2))
return -1;
+
if (hdr1->sh_addr < hdr2->sh_addr)
return -1;
else if (hdr1->sh_addr > hdr2->sh_addr)
@@ -2274,19 +2281,14 @@ elf_sort_hdrs (arg1, arg2)
ret = (hdr1->sh_type == SHT_NOBITS) - (hdr2->sh_type == SHT_NOBITS);
if (ret != 0)
return ret;
- if (hdr1->sh_size == 0)
+ if (hdr1->sh_size < hdr2->sh_size)
return -1;
- else if (hdr2->sh_size == 0)
- return 1;
- return 0;
- }
- else
- {
- if ((hdr2->sh_flags & SHF_ALLOC) != 0)
+ if (hdr1->sh_size > hdr2->sh_size)
return 1;
return 0;
}
-}
+
+
static boolean
prep_headers (abfd)