Index: src/bfd/peXXigen.c =================================================================== --- src.orig/bfd/peXXigen.c 2011-04-08 21:08:20.230411500 +0200 +++ src/bfd/peXXigen.c 2011-04-09 11:46:00.611507900 +0200 @@ -2458,15 +2458,23 @@ _bfd_XXi_final_link_postscript (bfd * ab if (sec) { - bfd_size_type x = sec->rawsize ? sec->rawsize : sec->size; + bfd_size_type x = sec->rawsize; + bfd_byte *tmp_data = NULL; - if (x && bfd_get_section_contents (abfd, sec, pfinfo->contents, 0, x)) + if (x) + tmp_data = bfd_malloc (x); + + if (tmp_data != 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); + if (bfd_get_section_contents (abfd, sec, tmp_data, 0, x)) + { + qsort (tmp_data, + (size_t) (x / 12), + 12, sort_x64_pdata); + bfd_set_section_contents (pfinfo->output_bfd, sec, + tmp_data, 0, x); + } + free (tmp_data); } } } Index: src/bfd/coffcode.h =================================================================== --- src.orig/bfd/coffcode.h 2011-04-09 10:29:19.000000000 +0200 +++ src/bfd/coffcode.h 2011-04-09 11:46:45.938100500 +0200 @@ -3297,6 +3297,11 @@ coff_compute_section_file_positions (bfd if (!(current->flags & SEC_HAS_CONTENTS)) continue; + /* Set rawsize for each section before we are doing alignment. But + don't set rawsize for BSS section. */ + if (strcmp (current->name, _BSS) != 0) + current->rawsize = current->size; + #ifdef COFF_IMAGE_WITH_PE /* Make sure we skip empty sections in a PE image. */ if (current->size == 0) @@ -3363,7 +3368,7 @@ coff_compute_section_file_positions (bfd #ifdef COFF_IMAGE_WITH_PE /* Set the padded size. */ - current->size = (current->size + page_size -1) & -page_size; + current->size = (current->size + page_size - 1) & -page_size; #endif sofar += current->size;