public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [GOLD Patch] Grammar additions to handle INCLUDE directives
@ 2011-11-11 20:12 Sterling Augustine
  2011-11-11 21:24 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Sterling Augustine @ 2011-11-11 20:12 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 913 bytes --]

Hi All,

This patch fixes up Gold's grammar so that script_include_directive
gets called whenever a it encounters a syntactically valid INCLUDE
directive.

Gnu.ld accepts the include directive in all of the following locations:

INCLUDE foo
MEMORY
{
	INCLUDE foo
	amemory : ORIGIN = 0, LENGTH = 16
}

SECTIONS
{
	INCLUDE foo
	.asection : { *(.asection)
	    INCLUDE foo
	  }
}

One could implement script_include_directive with a simple call to
read_script_file, but read_script_file doesn't do the directory-search
properly. Fixing the FIXME for relative paths there would be a big
step toward proper support for the INCLUDE directive, because the
semantics for the two cases are the same. It would probably need an
additional parameter though.

Sterling

2011-11-11  Sterling Augustine  <saugustine@google.com>

	* yyscript.y (section_cmd): Add support for INCLUDE directive.
	(file_or_sections_cmd): Likewise.

[-- Attachment #2: include.patch --]
[-- Type: text/x-patch, Size: 748 bytes --]

Index: yyscript.y
===================================================================
RCS file: /cvs/src/src/gold/yyscript.y,v
retrieving revision 1.26
diff -u -r1.26 yyscript.y
--- yyscript.y	8 Sep 2010 16:10:31 -0000	1.26
+++ yyscript.y	11 Nov 2011 20:06:21 -0000
@@ -528,6 +528,8 @@
 		 nothing, we accept it and ignore it.  */
 	    }
 	| SORT_BY_NAME '(' CONSTRUCTORS ')'
+	| INCLUDE string
+	  { script_include_directive(closure, $2.value, $2.length); }
 	| ';'
 	;
 
@@ -689,6 +691,8 @@
 	| assignment end
 	| ASSERT_K '(' parse_exp ',' string ')'
 	    { script_add_assertion(closure, $3, $5.value, $5.length); }
+	| INCLUDE string
+	  { script_include_directive(closure, $2.value, $2.length); }
 	;
 
 /* A list of MEMORY definitions.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [GOLD Patch] Grammar additions to handle INCLUDE directives
  2011-11-11 20:12 [GOLD Patch] Grammar additions to handle INCLUDE directives Sterling Augustine
@ 2011-11-11 21:24 ` Ian Lance Taylor
  2011-11-11 22:33   ` Sterling Augustine
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2011-11-11 21:24 UTC (permalink / raw)
  To: Sterling Augustine; +Cc: binutils

Sterling Augustine <saugustine@google.com> writes:

> 2011-11-11  Sterling Augustine  <saugustine@google.com>
>
> 	* yyscript.y (section_cmd): Add support for INCLUDE directive.
> 	(file_or_sections_cmd): Likewise.
>
> Index: yyscript.y
> ===================================================================
> RCS file: /cvs/src/src/gold/yyscript.y,v
> retrieving revision 1.26
> diff -u -r1.26 yyscript.y
> --- yyscript.y	8 Sep 2010 16:10:31 -0000	1.26
> +++ yyscript.y	11 Nov 2011 20:06:21 -0000
> @@ -528,6 +528,8 @@
>  		 nothing, we accept it and ignore it.  */
>  	    }
>  	| SORT_BY_NAME '(' CONSTRUCTORS ')'
> +	| INCLUDE string
> +	  { script_include_directive(closure, $2.value, $2.length); }
>  	| ';'
>  	;
>  
> @@ -689,6 +691,8 @@
>  	| assignment end
>  	| ASSERT_K '(' parse_exp ',' string ')'
>  	    { script_add_assertion(closure, $3, $5.value, $5.length); }
> +	| INCLUDE string
> +	  { script_include_directive(closure, $2.value, $2.length); }
>  	;
>  
>  /* A list of MEMORY definitions.  */


The indentation looks wrong.  The left brace should be under the 'C', or
in other words it should line up under the other left braces in the
file.  (It's wrong in the other call to script_include_directive also).

This is OK if you fix that, or if it is already correct and just munged
by diff or mail.

Thanks.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [GOLD Patch] Grammar additions to handle INCLUDE directives
  2011-11-11 21:24 ` Ian Lance Taylor
@ 2011-11-11 22:33   ` Sterling Augustine
  0 siblings, 0 replies; 3+ messages in thread
From: Sterling Augustine @ 2011-11-11 22:33 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

On Fri, Nov 11, 2011 at 1:24 PM, Ian Lance Taylor <iant@google.com> wrote:
> The indentation looks wrong.  The left brace should be under the 'C', or
> in other words it should line up under the other left braces in the
> file.  (It's wrong in the other call to script_include_directive also).

A copy and paste error and weak yacc-reading skills combined for this failure.

But fixed and committed.

Sterling

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-11-11 22:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-11 20:12 [GOLD Patch] Grammar additions to handle INCLUDE directives Sterling Augustine
2011-11-11 21:24 ` Ian Lance Taylor
2011-11-11 22:33   ` Sterling Augustine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).