This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[GOLD Patch] Grammar additions to handle INCLUDE directives
- From: Sterling Augustine <saugustine at google dot com>
- To: binutils at sourceware dot org
- Date: Fri, 11 Nov 2011 12:12:38 -0800
- Subject: [GOLD Patch] Grammar additions to handle INCLUDE directives
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.
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. */