This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit]: Fix sizing of empty sections in PE format output


Hi Guys,

  I am checking in the patch below to fix a problem with sizing of
  empty sections in PE format output files.  Just because a section is
  empty does not mean it has no size.  The linker script for such a
  section may include assignments to dot giving them a non-zero size.
  An example of this is the .cygheap section in the Cygwin linker
  script which has to be at least 512K in size and have 64K alignment,
  even if there are no input sections to assign to it.

  The problem was that the code in pe_exe_fill_sections() was
  computing the section sizes twice without resetting the sizes back
  to zero between the two passes.  For non-empty output sections this
  did not matter as the code to increment dot as each input section is
  assigned to the corresponding output section would effectively reset
  the size value.  But for empty output sections this does not happen
  and so the second pass has the effect of doubling the size of those
  sections.  For the Cygwin linker script this breaks the alignment of
  the .cygheap section, causing all kinds of havoc.

Cheers
  Nick

ld/ChangeLog
2005-08-10  Nick Clifton  <nickc@redhat.com>

	* pe-dll.c (pe_exe_fill_sections): Call lang_reset_memory_regions
	before lang_size_sections.

Index: ld/pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.79
diff -c -3 -p -r1.79 pe-dll.c
*** ld/pe-dll.c	9 Jun 2005 02:05:46 -0000	1.79
--- ld/pe-dll.c	10 Aug 2005 10:39:49 -0000
*************** pe_dll_fill_sections (bfd *abfd, struct 
*** 2636,2641 ****
--- 2636,2642 ----
        bfd_set_section_size (filler_bfd, reloc_s, reloc_sz);
  
        /* Resize the sections.  */
+       lang_reset_memory_regions ();
        lang_size_sections (NULL, TRUE);
  
        /* Redo special stuff.  */
*************** pe_exe_fill_sections (bfd *abfd, struct 
*** 2666,2671 ****
--- 2667,2673 ----
        bfd_set_section_size (filler_bfd, reloc_s, reloc_sz);
  
        /* Resize the sections.  */
+       lang_reset_memory_regions ();
        lang_size_sections (NULL, TRUE);
  
        /* Redo special stuff.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]