Index: src/bfd/peXXigen.c =================================================================== --- src.orig/bfd/peXXigen.c 2010-09-13 09:07:32.435479900 +0200 +++ src/bfd/peXXigen.c 2010-09-14 19:13:31.626349200 +0200 @@ -2256,6 +2256,26 @@ coff_get_symbol_info (abfd, symbol, ret); } +#if !defined(COFF_WITH_pep) && defined(COFF_WITH_pex64) +static int +sort_x64_pdata (const void *l, const void *r) +{ + const char *lp = (const char *) l; + const char *rp = (const char *) r; + bfd_vma vl, vr; + vl = bfd_getl32 (lp); vr = bfd_getl32 (rp); + if (vl != vr) + return (vl < vr ? -1 : 1); + vl = bfd_getl32 (lp + 4); vr = bfd_getl32 (rp + 4); + if (vl != vr) + return (vl < vr ? -1 : 1); + vl = bfd_getl32 (lp + 8); vr = bfd_getl32 (rp + 8); + if (vl != vr) + return (vl < vr ? -1 : 1); + return 0; +} +#endif + /* Handle the .idata section and other things that need symbol table access. */ @@ -2383,6 +2403,29 @@ pe_data (abfd)->pe_opthdr.DataDirectory[PE_TLS_TABLE].Size = 0x18; } +/* If there is a .pdata section and we have linked pdata finally, we + need to sort the entries ascending. */ +#if !defined(COFF_WITH_pep) && defined(COFF_WITH_pex64) + { + asection *sec = bfd_get_section_by_name (abfd, ".pdata"); + + if (sec) + { + bfd_size_type x = sec->rawsize ? sec->rawsize : sec->size; + + if (x && bfd_get_section_contents (abfd, sec, pfinfo->contents, 0, x) + && pfinfo->contents != NULL) + { + qsort (pfinfo->contents, + (size_t) ((sec->size size : x) / 12), + 12, sort_x64_pdata); + bfd_set_section_contents (pfinfo->output_bfd, sec, + pfinfo->contents, 0, x); + } + } + } +#endif + /* If we couldn't find idata$2, we either have an excessively trivial program or are in DEEP trouble; we have to assume trivial program.... */