From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22010 invoked by alias); 26 Feb 2011 00:45:42 -0000 Received: (qmail 22001 invoked by uid 22791); 26 Feb 2011 00:45:41 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-wy0-f169.google.com (HELO mail-wy0-f169.google.com) (74.125.82.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 26 Feb 2011 00:45:36 +0000 Received: by mail-wy0-f169.google.com with SMTP id 11so2568837wyi.0 for ; Fri, 25 Feb 2011 16:45:36 -0800 (PST) Received: by 10.227.32.69 with SMTP id b5mr2737713wbd.11.1298681136217; Fri, 25 Feb 2011 16:45:36 -0800 (PST) Received: from [192.168.2.99] (cpc2-cmbg8-0-0-cust61.5-4.cable.virginmedia.com [82.6.108.62]) by mx.google.com with ESMTPS id f27sm1031522wbf.1.2011.02.25.16.45.34 (version=SSLv3 cipher=OTHER); Fri, 25 Feb 2011 16:45:35 -0800 (PST) Message-ID: <4D684D1C.9090002@gmail.com> Date: Sat, 26 Feb 2011 00:45:00 -0000 From: Dave Korn User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: "binutils@sourceware.org" Subject: [1/6][PATCH] Fix PE-COFF bug in orphan section alignment handling. References: <4D684CB8.6020106@gmail.com> <4D684D00.70803@gmail.com> In-Reply-To: <4D684D00.70803@gmail.com> Content-Type: multipart/mixed; boundary="------------070600080200040708080200" Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00329.txt.bz2 This is a multi-part message in MIME format. --------------070600080200040708080200 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 644 Hi list, Fixes a problem with orphan section alignment in the PE-COFF linker, this was causing "ld -r" of objects containing LTO sections to break. 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. I could just approve and commit this myself, but since it came up as part of developing the series I'll post it for comment anyway, in case there's perhaps a better way to do what I want. cheers, DaveK --------------070600080200040708080200 Content-Type: text/x-c; name="001ld-pe-orphan-section-alignment.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="001ld-pe-orphan-section-alignment.diff" Content-length: 2481 >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 '\$' --------------070600080200040708080200--