From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5316 invoked by alias); 24 Nov 2005 00:57:08 -0000 Received: (qmail 5308 invoked by uid 22791); 24 Nov 2005 00:57:07 -0000 X-Spam-Check-By: sourceware.org Received: from CPE-144-136-167-90.sa.bigpond.net.au (HELO grove.modra.org) (144.136.167.90) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 24 Nov 2005 00:57:07 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 500) id DE1E7190027; Thu, 24 Nov 2005 11:27:03 +1030 (CST) Date: Thu, 24 Nov 2005 00:57:00 -0000 From: Alan Modra To: binutils@sourceware.org Subject: Re: Section sizing + orphan placement bugs Message-ID: <20051124005703.GE19599@bubble.grove.modra.org> Mail-Followup-To: binutils@sourceware.org References: <20051123163654.GA15886@nevyn.them.org> <20051124003957.GD19599@bubble.grove.modra.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051124003957.GD19599@bubble.grove.modra.org> User-Agent: Mutt/1.4i X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2005-11/txt/msg00346.txt.bz2 On Thu, Nov 24, 2005 at 11:09:57AM +1030, Alan Modra wrote: > On Wed, Nov 23, 2005 at 11:36:54AM -0500, Daniel Jacobowitz wrote: > > I think the attached fix is right for that part of the bug but I'm open to > > suggestions on how to handle SIZEOF_HEADERS. > > I'll fix that bit. Like this. * ldlang.c (lang_insert_orphan): Skip first assignment to dot in script when looking for place to insert orphan statements. Index: ld/ldlang.c =================================================================== RCS file: /cvs/src/src/ld/ldlang.c,v retrieving revision 1.208 diff -u -p -r1.208 ldlang.c --- ld/ldlang.c 18 Nov 2005 04:12:27 -0000 1.208 +++ ld/ldlang.c 24 Nov 2005 00:54:47 -0000 @@ -1467,13 +1467,20 @@ lang_insert_orphan (asection *s, { lang_statement_union_type **where; lang_statement_union_type **assign = NULL; + bfd_boolean ignore_first; /* Look for a suitable place for the new statement list. The idea is to skip over anything that might be inside a SECTIONS {} statement in a script, before we find another output_section_statement. Assignments to "dot" before an output section statement are assumed to - belong to it. */ + belong to it. An exception to this rule is made for + the first assignment to dot, otherwise we might put an + orphan before . = . + SIZEOF_HEADERS or similar + assignments that set the initial address. */ + + ignore_first = after == (&lang_output_section_statement.head + ->output_section_statement); for (where = &after->header.next; *where != NULL; where = &(*where)->header.next) @@ -1487,9 +1494,11 @@ lang_insert_orphan (asection *s, ass = &(*where)->assignment_statement; if (ass->exp->type.node_class != etree_assert && ass->exp->assign.dst[0] == '.' - && ass->exp->assign.dst[1] == 0) + && ass->exp->assign.dst[1] == 0 + && !ignore_first) assign = where; } + ignore_first = FALSE; continue; case lang_wild_statement_enum: case lang_input_section_enum: -- Alan Modra IBM OzLabs - Linux Technology Centre