From 1aefb61e70c166a04e79afba432082247bd69e77 Mon Sep 17 00:00:00 2001 From: Dave Korn Date: Sat, 19 Feb 2011 23:18:55 +0000 Subject: [PATCH] Fix PE-COFF bug in orphan section alignment handling. ld/ChangeLog: 2011-02-20 Dave Korn <... * 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/emultempl/pe.em | 7 ++++++- ld/emultempl/pep.em | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index a3e4cdd..55041f3 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -2007,10 +2007,15 @@ 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->bfd_section->alignment_power = os->section_alignment + = s->alignment_power; } /* If the section name has a '\$', sort it with the other '\$' diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index a307c14..51dffff 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -1746,10 +1746,15 @@ 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->bfd_section->alignment_power = os->section_alignment + = s->alignment_power; } /* If the section name has a '\$', sort it with the other '\$'