[PATCH] Fix PE-COFF bug in orphan section alignment handling.
authorDave Korn <dave.korn@artimi.com>
Thu, 10 Mar 2011 10:20:26 +0000 (10:20 +0000)
committerDave Korn <dave.korn@artimi.com>
Thu, 10 Mar 2011 10:20:26 +0000 (10:20 +0000)
ld/ChangeLog:

2011-03-10  Dave Korn  <dave.korn.cygwin@gmail.com>

* emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Preserve
alignment of input sections when creating orphan output sections
during relocatable link.
* emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise.

ld/ChangeLog
ld/emultempl/pe.em
ld/emultempl/pep.em

index bdf4b01ec42082d738057708cb9b4eb51a662c25..d3c5235571d1ce707f7086526c60bd664a34bbe1 100644 (file)
@@ -1,3 +1,10 @@
+2011-03-10  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+       * emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Preserve
+       alignment of input sections when creating orphan output sections
+       during relocatable link.
+       * emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
+
 2011-03-04  H.J. Lu  <hongjiu.lu@intel.com>
 
        * ld.texinfo: Document --verbose[=NUMBER].
index 9b800cde691b3d067e32feecd1cb2a53ca1509a6..b8290b3435bf3e02794f3600c48a671d9d625d21 100644 (file)
@@ -2009,10 +2009,17 @@ gld_${EMULATION_NAME}_place_orphan (asection *s,
                     ->output_section_statement);
        }
 
-      /* All sections in an executable must be aligned to a page boundary.  */
+      /* All sections in an executable must be aligned to a page boundary.
+        In a relocatable link, just preserve the incoming alignment; the
+        address is discarded by lang_insert_orphan in that case, anyway.  */
       address = exp_unop (ALIGN_K, exp_nameop (NAME, "__section_alignment__"));
       os = lang_insert_orphan (s, secname, constraint, after, place, address,
                               &add_child);
+      if (link_info.relocatable)
+       {
+         os->section_alignment = s->alignment_power;
+         os->bfd_section->alignment_power = s->alignment_power;
+       }
     }
 
   /* If the section name has a '\$', sort it with the other '\$'
index 2119367cbdaf0f9a2dc8c8584f8cfeaabf3f347e..0c1dfb97539427fdfc02d8754e00e4a85bbd99fe 100644 (file)
@@ -1748,10 +1748,17 @@ gld_${EMULATION_NAME}_place_orphan (asection *s,
                     ->output_section_statement);
        }
 
-      /* All sections in an executable must be aligned to a page boundary.  */
+      /* All sections in an executable must be aligned to a page boundary.
+        In a relocatable link, just preserve the incoming alignment; the
+        address is discarded by lang_insert_orphan in that case, anyway.  */
       address = exp_unop (ALIGN_K, exp_nameop (NAME, "__section_alignment__"));
       os = lang_insert_orphan (s, secname, constraint, after, place, address,
                               &add_child);
+      if (link_info.relocatable)
+       {
+         os->section_alignment = s->alignment_power;
+         os->bfd_section->alignment_power = s->alignment_power;
+       }
     }
 
   /* If the section name has a '\$', sort it with the other '\$'
This page took 0.045524 seconds and 4 git commands to generate.