diff options
author | Cary Coutant <ccoutant@gmail.com> | 2015-03-21 19:03:00 -0700 |
---|---|---|
committer | Cary Coutant <ccoutant@gmail.com> | 2015-03-21 19:54:15 -0700 |
commit | 410da591ba7814912e11be826b20dfba9abed9f7 (patch) | |
tree | faf2cf11ec24592cfb68657240e3a620e9e357a9 /gold/yyscript.y | |
parent | 0d5bbdb0e1d193fa6f6804f2620fbdfc950c57a4 (diff) | |
download | gdb-410da591ba7814912e11be826b20dfba9abed9f7.zip gdb-410da591ba7814912e11be826b20dfba9abed9f7.tar.gz gdb-410da591ba7814912e11be826b20dfba9abed9f7.tar.bz2 |
PR gold/18048: Fix INCLUDE directive support for gold
This patch fixes INCLUDE directives in script files, so that when
an INCLUDE appears inside a sections block, section commands block,
or memory def block, the contents are parsed in the appropriate
context.
gold/
PR gold/18048
* script-c.h (script_include_directive): Add first_token parameter.
* script.cc (script_include_directive): Add first_token parameter, and
pass it to read_script_file.
* yyscript.y (PARSING_SECTIONS_BLOCK, PARSING_SECTION_CMDS)
(PARSING_MEMORY_DEF): New tokens.
(top): Add new productions for INCLUDE files.
(file_cmd): Replace file_or_sections_cmd with copy of its productions.
Pass PARSING_LINKER_SCRIPT to script_include_directive.
(section_block_cmd): Likewise; pass PARSING_SECTIONS_BLOCK.
(section_cmd): Pass PARSING_SECTION_CMDS.
(file_or_sections_cmd): Remove.
(memory_def): Pass PARSING_MEMORY_DEF.
* testsuite/Makefile.am (memory_test_2): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/memory_test_inc.t: New script file.
* testsuite/memory_test_inc_1.t.src: New script file.
* testsuite/memory_test_inc_2.t.src: New script file.
* testsuite/memory_test_inc_3.t.src: New script file.
Diffstat (limited to 'gold/yyscript.y')
-rw-r--r-- | gold/yyscript.y | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/gold/yyscript.y b/gold/yyscript.y index 87aab58..b519f54 100644 --- a/gold/yyscript.y +++ b/gold/yyscript.y @@ -201,6 +201,9 @@ %token PARSING_VERSION_SCRIPT %token PARSING_DEFSYM %token PARSING_DYNAMIC_LIST +%token PARSING_SECTIONS_BLOCK +%token PARSING_SECTION_COMMANDS +%token PARSING_MEMORY_DEF /* Non-terminal types, where needed. */ @@ -232,6 +235,9 @@ top: | PARSING_VERSION_SCRIPT version_script | PARSING_DEFSYM defsym_expr | PARSING_DYNAMIC_LIST dynamic_list_expr + | PARSING_SECTIONS_BLOCK sections_block + | PARSING_SECTION_COMMANDS section_cmds + | PARSING_MEMORY_DEF memory_defs ; /* A file contains a list of commands. */ @@ -281,7 +287,14 @@ file_cmd: { script_push_lex_into_version_mode(closure); } version_script '}' { script_pop_lex_mode(closure); } - | file_or_sections_cmd + | ENTRY '(' string ')' + { script_set_entry(closure, $3.value, $3.length); } + | assignment end + | ASSERT_K '(' parse_exp ',' string ')' + { script_add_assertion(closure, $3, $5.value, $5.length); } + | INCLUDE string + { script_include_directive(PARSING_LINKER_SCRIPT, closure, + $2.value, $2.length); } | ignore_cmd | ';' ; @@ -339,7 +352,14 @@ sections_block: /* A command which may appear within a SECTIONS block. */ section_block_cmd: - file_or_sections_cmd + ENTRY '(' string ')' + { script_set_entry(closure, $3.value, $3.length); } + | assignment end + | ASSERT_K '(' parse_exp ',' string ')' + { script_add_assertion(closure, $3, $5.value, $5.length); } + | INCLUDE string + { script_include_directive(PARSING_SECTIONS_BLOCK, closure, + $2.value, $2.length); } | string section_header { script_start_output_section(closure, $1.value, $1.length, &$2); } '{' section_cmds '}' section_trailer @@ -529,7 +549,8 @@ section_cmd: } | SORT_BY_NAME '(' CONSTRUCTORS ')' | INCLUDE string - { script_include_directive(closure, $2.value, $2.length); } + { script_include_directive(PARSING_SECTION_COMMANDS, closure, + $2.value, $2.length); } | ';' ; @@ -683,18 +704,6 @@ wildcard_name: } ; -/* A command which may appear at the top level of a linker script, or - within a SECTIONS block. */ -file_or_sections_cmd: - ENTRY '(' string ')' - { script_set_entry(closure, $3.value, $3.length); } - | 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. */ memory_defs: memory_defs opt_comma memory_def @@ -706,9 +715,9 @@ memory_def: string memory_attr ':' memory_origin '=' parse_exp opt_comma memory_length '=' parse_exp { script_add_memory(closure, $1.value, $1.length, $2, $6, $10); } | - /* LD supports an INCLUDE directive here, currently GOLD does not. */ INCLUDE string - { script_include_directive(closure, $2.value, $2.length); } + { script_include_directive(PARSING_MEMORY_DEF, closure, + $2.value, $2.length); } | ; |