From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28328 invoked by alias); 27 Sep 2005 19:12:27 -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 28311 invoked by uid 22791); 27 Sep 2005 19:12:19 -0000 Received: from smtp110.sbc.mail.mud.yahoo.com (HELO smtp110.sbc.mail.mud.yahoo.com) (68.142.198.209) by sourceware.org (qpsmtpd/0.30-dev) with SMTP; Tue, 27 Sep 2005 19:12:19 +0000 Received: (qmail 11753 invoked from network); 27 Sep 2005 19:12:17 -0000 Received: from unknown (HELO lucon.org) (hjjean@sbcglobal.net@67.122.69.173 with login) by smtp110.sbc.mail.mud.yahoo.com with SMTP; 27 Sep 2005 19:12:17 -0000 Received: by lucon.org (Postfix, from userid 1000) id 95C75653D8; Tue, 27 Sep 2005 12:12:15 -0700 (PDT) Date: Tue, 27 Sep 2005 21:21:00 -0000 From: "H. J. Lu" To: binutils@sources.redhat.com Subject: Re: PATCH: Fix empty sections with alignment Message-ID: <20050927191215.GA14562@lucon.org> References: <20050926223601.GA28885@lucon.org> <20050927023315.GE29044@bubble.grove.modra.org> <20050927150405.GA10788@lucon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050927150405.GA10788@lucon.org> User-Agent: Mutt/1.4.1i X-SW-Source: 2005-09/txt/msg00306.txt.bz2 On Tue, Sep 27, 2005 at 08:04:05AM -0700, H. J. Lu wrote: > > > > Instead, I think we need some linker script construct that allows us to > > increase the alignment of an output section over that specified by its > > input sections, other than using ALIGN() as the address. Perhaps an > > ALIGN() after the semicolon. lang_enter_output_section_statement > > already supports an output section alignment. > > I will look into it. > Here is the patch to allow ALIGN to be used to force output section alignment. H.J. ---- 2005-09-27 H.J. Lu * ld.texinfo (ALIGN): Document it as forcing output section alignment. * ldgram.y (ALIGN): Support it for forcing output section alignment. --- ld/ld.texinfo.align 2005-09-26 13:12:55.000000000 -0700 +++ ld/ld.texinfo 2005-09-27 10:11:16.000000000 -0700 @@ -3067,7 +3067,7 @@ The full description of an output sectio @smallexample @group @var{section} [@var{address}] [(@var{type})] : - [AT(@var{lma})] [SUBALIGN(@var{subsection_align})] + [AT(@var{lma})] [ALIGN(@var{section_align})] [SUBALIGN(@var{subsection_align})] @{ @var{output-section-command} @var{output-section-command} @@ -3643,7 +3643,7 @@ like this: @smallexample @group @var{section} [@var{address}] [(@var{type})] : - [AT(@var{lma})] [SUBALIGN(@var{subsection_align})] + [AT(@var{lma})] [ALIGN(@var{section_align})] [SUBALIGN(@var{subsection_align})] @{ @var{output-section-command} @var{output-section-command} @@ -3658,6 +3658,7 @@ remaining section attributes. @menu * Output Section Type:: Output section type * Output Section LMA:: Output section LMA +* Forced Output Alignment:: Forced Output Alignment * Forced Input Alignment:: Forced Input Alignment * Output Section Region:: Output section region * Output Section Phdr:: Output section phdr @@ -3771,6 +3772,15 @@ for (dst = &_bstart; dst< &_bend; dst++) @end group @end smallexample +@node Forced Output Alignment +@subsubsection Forced Output Alignment +@kindex ALIGN(@var{section_align}) +@cindex forcing output section alignment +@cindex output section alignment +You can force an output section alignment by using ALIGN. The value +specified overrides any alignment given by input sections, whether +larger or smaller. + @node Forced Input Alignment @subsubsection Forced Input Alignment @kindex SUBALIGN(@var{subsection_align}) --- ld/ldgram.y.align 2005-09-26 13:12:55.000000000 -0700 +++ ld/ldgram.y 2005-09-27 10:04:14.000000000 -0700 @@ -92,7 +92,7 @@ static int error_index; } %type exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val -%type opt_exp_without_type opt_subalign +%type opt_exp_without_type opt_subalign opt_align %type fill_opt fill_exp %type exclude_name_list %type file_NAME_list @@ -892,6 +892,11 @@ opt_at: | { $$ = 0; } ; +opt_align: + ALIGN_K '(' exp ')' { $$ = $3; } + | { $$ = 0; } + ; + opt_subalign: SUBALIGN '(' exp ')' { $$ = $3; } | { $$ = 0; } @@ -907,20 +912,21 @@ sect_constraint: section: NAME { ldlex_expression(); } opt_exp_with_type opt_at + opt_align opt_subalign { ldlex_popstate (); ldlex_script (); } sect_constraint '{' { lang_enter_output_section_statement($1, $3, sectype, - 0, $5, $4, $7); + $5, $6, $4, $8); } statement_list_opt '}' { ldlex_popstate (); ldlex_expression (); } memspec_opt memspec_at_opt phdr_opt fill_opt { ldlex_popstate (); - lang_leave_output_section_statement ($16, $13, $15, $14); + lang_leave_output_section_statement ($17, $14, $16, $15); } opt_comma {}