+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
/* 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)
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)