From: Steve Chamberlain Date: Fri, 9 Jun 1995 19:21:47 +0000 (+0000) Subject: * elfcode.h (elf_sort_hdrs): Rewrite to be symmetrical. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d1ec549d7b021c9c1612f3bae4bf5478d3fed56c;p=binutils-gdb.git * elfcode.h (elf_sort_hdrs): Rewrite to be symmetrical. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 45750f1cd3c..35ab78641f6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,7 @@ +Fri Jun 9 12:20:28 1995 Steve Chamberlain + + * 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 4155cde43ab..63b55f433fc 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)