From 195e7dc6c1d9ed2d3ea5dca8c7798799383b7341 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 26 Oct 2007 22:16:06 +0000 Subject: [PATCH] From Craig Silverstein: preliminary support for OPTION in linker script. --- gold/script-c.h | 4 ++++ gold/script.cc | 10 ++++++++++ gold/yyscript.y | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/gold/script-c.h b/gold/script-c.h index cb0ef8ec69d..1214800dd0a 100644 --- a/gold/script-c.h +++ b/gold/script-c.h @@ -66,6 +66,10 @@ script_start_as_needed(void* closure); extern void script_end_as_needed(void* closure); +/* Called by the bison parser to parse an OPTION. */ +extern void +script_parse_option(void* closure, const char*); + #ifdef __cplusplus } #endif diff --git a/gold/script.cc b/gold/script.cc index 2cea0c88787..08be65f0b98 100644 --- a/gold/script.cc +++ b/gold/script.cc @@ -1045,6 +1045,7 @@ Keyword_to_parsecode::keyword_parsecodes_[] = { "NOLOAD", NOLOAD }, { "ONLY_IF_RO", ONLY_IF_RO }, { "ONLY_IF_RW", ONLY_IF_RW }, + { "OPTION", OPTION }, { "ORIGIN", ORIGIN }, { "OUTPUT", OUTPUT }, { "OUTPUT_ARCH", OUTPUT_ARCH }, @@ -1257,3 +1258,12 @@ script_end_as_needed(void* closurev) Parser_closure* closure = static_cast(closurev); closure->position_dependent_options().clear_as_needed(); } + +// Called by the bison parser to parse an OPTION. + +extern "C" void +script_parse_option(void* closurev, const char* option) +{ + Parser_closure* closure = static_cast(closurev); + printf("%s: Saw option %s\n", closure->filename(), option); //!! +} diff --git a/gold/yyscript.y b/gold/yyscript.y index b78c09b5662..3250e8ed2d7 100644 --- a/gold/yyscript.y +++ b/gold/yyscript.y @@ -151,6 +151,13 @@ %token TRUNCATE %token VERSIONK /* VERSION */ +/* Keywords, part 2. These are keywords that are unique to gold, + and not present in the old GNU linker. As before, unless the + comments say otherwise, the keyword is recognized as the token + name in upper case. */ + +%token OPTION + %% file_list: @@ -164,6 +171,8 @@ file_cmd: { script_start_group(closure); } '(' input_list ')' { script_end_group(closure); } + | OPTION '(' STRING ')' + { script_parse_option(closure, $3); } ; input_list: -- 2.30.2