* elfcode.h (elf_sort_hdrs): Rewrite to be symmetrical.

This commit is contained in:
Steve Chamberlain 1995-06-09 19:21:47 +00:00
parent 3b1f83adad
commit d1ec549d7b
2 changed files with 19 additions and 13 deletions

View File

@ -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

View File

@ -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)
if (hdr1->sh_size > hdr2->sh_size)
return 1;
return 0;
}
else
{
if ((hdr2->sh_flags & SHF_ALLOC) != 0)
return 1;
return 0;
}
}
static boolean
prep_headers (abfd)