From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25829 invoked by alias); 26 Aug 2004 16:49:06 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 25778 invoked from network); 26 Aug 2004 16:49:03 -0000 Received: from unknown (HELO sccrmhc13.comcast.net) (204.127.202.64) by sourceware.org with SMTP; 26 Aug 2004 16:49:03 -0000 Received: from lucon.org ([24.6.43.109]) by comcast.net (sccrmhc13) with ESMTP id <2004082616490301600k18u6e>; Thu, 26 Aug 2004 16:49:03 +0000 Received: by lucon.org (Postfix, from userid 1000) id 9618563F4B; Thu, 26 Aug 2004 09:49:01 -0700 (PDT) Date: Thu, 26 Aug 2004 16:49:00 -0000 From: "H. J. Lu" To: DJ Delorie Cc: binutils@sources.redhat.com Subject: Re: RFC: Add --sort-section to ld Message-ID: <20040826164901.GA734@lucon.org> References: <20040825210758.GA14687@lucon.org> <20040826005726.GA18117@lucon.org> <200408260155.i7Q1tdBa013315@greed.delorie.com> <20040826061301.GA22783@lucon.org> <200408261313.i7QDDYgv020208@greed.delorie.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200408261313.i7QDDYgv020208@greed.delorie.com> User-Agent: Mutt/1.4.1i X-SW-Source: 2004-08/txt/msg00339.txt.bz2 On Thu, Aug 26, 2004 at 09:13:34AM -0400, DJ Delorie wrote: > > > How do we deal with SORT in linker script and --sort-section alignment? > > Which one should be preferred? Should there be SORT_ALIGN? > > IMHO... > > The linker script always overrides the command line. > > However, it would make sense for the --sort-section function to be > used by the explicit SORT* routine for cases when the two sections > would otherwise sort equally, so sections whose order would otherwise > be unspecified would become specified. How about this proposal? H.J. ---- New input section sorting options in linker 1. New linker script section sorting commands. 1.1. Rename SORT to SORT_BY_NAME and make SORT an alias of SORT_BY_NAME. 1.2. Add SORT_BY_ALIGNMENT, which appears before a wildcard pattern in parentheses (.e.g. `SORT_BY_ALIGNMENT (.text*).). It will sort sections into ascending order by alignment before placing them into the output file. 2. New linker command line option. 2.1. --sort-section name. It will apply SORT_BY_NAME to all wildcard section patterns in the linker script. 2.2. --sort-section alignment. It will apply SORT_BY_ALIGMENT to all wildcard section patterns in the linker script. 3. Nesting of section sorting commands in linker script. There can be at most 1 level of nesting for section sorting commands. 3.1. SORT_BY_NAME (SORT_BY_ALIGNMENT (wildcard section pattern)). It will sort the input sections by alignment first, then by name if 2 sections have the same alignment. 3.2. SORT_BY_ALIGNMENT (SORT_BY_NAME (wildcard section pattern)). It will sort the input sections by name first, then by alignment if 2 sections have the same name. 3.3. SORT_BY_NAME (SORT_BY_NAME (wildcard section pattern)) is treated the same as SORT_BY_NAME (wildcard section pattern). 3.4. SORT_BY_ALIGNMENT (SORT_BY_ALIGMENT (wildcard section pattern)) is treated the same as SORT_BY_ALIGMENT (wildcard section pattern). 3.5. All other nested section sorting commands are invalid. 4. --sort-section command line option vs. section sorting command in linker script. 4.1. Section sorting commands always take precedent over the command line option. 4.2. If the section sorting command in linker script isn.t nested, the command line option will make the section sorting command to be treated as nested sorting command. 4.3. If the section sorting command in linker script is nested, the command line option will be ignored.