diff options
author | Ian Lance Taylor <iant@google.com> | 2007-10-30 06:27:03 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-10-30 06:27:03 +0000 |
commit | a0451b389c933e7b8938bdaa5c057c2c9a7428f1 (patch) | |
tree | fc157d8c6e4e7f860a1efccf089d42785b134cb0 /gold/script.cc | |
parent | c1866bd5e3eadb2b03515e13f7e8a4dc7377762a (diff) | |
download | gdb-a0451b389c933e7b8938bdaa5c057c2c9a7428f1.zip gdb-a0451b389c933e7b8938bdaa5c057c2c9a7428f1.tar.gz gdb-a0451b389c933e7b8938bdaa5c057c2c9a7428f1.tar.bz2 |
From Craig Silverstein: Implement OPTION in linker scripts.
Diffstat (limited to 'gold/script.cc')
-rw-r--r-- | gold/script.cc | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/gold/script.cc b/gold/script.cc index 64894ca..83e490c 100644 --- a/gold/script.cc +++ b/gold/script.cc @@ -831,9 +831,11 @@ class Parser_closure Parser_closure(const char* filename, const Position_dependent_options& posdep_options, bool in_group, bool is_in_sysroot, + Command_line* command_line, const Lex::Token_sequence* tokens) : filename_(filename), posdep_options_(posdep_options), - in_group_(in_group), is_in_sysroot_(is_in_sysroot), tokens_(tokens), + in_group_(in_group), is_in_sysroot_(is_in_sysroot), + command_line_(command_line), tokens_(tokens), next_token_index_(0), inputs_(NULL) { } @@ -859,6 +861,12 @@ class Parser_closure is_in_sysroot() const { return this->is_in_sysroot_; } + // Returns the Command_line structure passed in at constructor time. + // This value may be NULL. The caller may modify this, which modifies + // the passed-in Command_line object (not a copy). + Command_line* command_line() + { return this->command_line_; } + // Whether we are at the end of the token list. bool at_eof() const @@ -897,6 +905,8 @@ class Parser_closure bool in_group_; // Whether the script was found in a sysrooted directory. bool is_in_sysroot_; + // May be NULL if the user chooses not to pass one in. + Command_line* command_line_; // The tokens to be returned by the lexer. const Lex::Token_sequence* tokens_; @@ -927,6 +937,7 @@ read_input_script(Workqueue* workqueue, const General_options& options, input_argument->file().options(), input_group != NULL, input_file->is_in_sysroot(), + NULL, &lex.tokens()); if (yyparse(&closure) != 0) @@ -973,9 +984,8 @@ read_input_script(Workqueue* workqueue, const General_options& options, bool read_commandline_script(const char* filename, Command_line* cmdline) { - // We don't need to use the real directory search path here: - // FILENAME was specified on the command line, and we don't want to - // search for it. + // TODO: if filename is a relative filename, search for it manually + // using "." + cmdline->options()->search_path() -- not dirsearch. Dirsearch dirsearch; Input_file_argument input_argument(filename, false, "", @@ -996,6 +1006,7 @@ read_commandline_script(const char* filename, Command_line* cmdline) cmdline->position_dependent_options(), false, input_file.is_in_sysroot(), + cmdline, &lex.tokens()); if (yyparse(&closure) != 0) { @@ -1306,5 +1317,22 @@ extern "C" void script_parse_option(void* closurev, const char* option) { Parser_closure* closure = static_cast<Parser_closure*>(closurev); - printf("%s: Saw option %s\n", closure->filename(), option); //!! + // We treat the option as a single command-line option, even if + // it has internal whitespace. + if (closure->command_line() == NULL) + { + // There are some options that we could handle here--e.g., + // -lLIBRARY. Should we bother? + gold_warning(_("%s: Ignoring command OPTION; OPTION is only valid" + " for scripts specified via -T"), + closure->filename()); + } + else + { + bool past_a_double_dash_option = false; + char* mutable_option = strdup(option); + closure->command_line()->process_one_option(1, &mutable_option, 0, + &past_a_double_dash_option); + free(mutable_option); + } } |