diff options
Diffstat (limited to 'binutils-2.22/gold/script.cc')
-rw-r--r-- | binutils-2.22/gold/script.cc | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/binutils-2.22/gold/script.cc b/binutils-2.22/gold/script.cc index 7df0c9e..6a10c40 100644 --- a/binutils-2.22/gold/script.cc +++ b/binutils-2.22/gold/script.cc @@ -983,18 +983,20 @@ Symbol_assignment::sized_finalize(Symbol_table* symtab, const Layout* layout, uint64_t final_val = this->val_->eval_maybe_dot(symtab, layout, true, is_dot_available, dot_value, dot_section, - §ion, NULL); + §ion, NULL, false); Sized_symbol<size>* ssym = symtab->get_sized_symbol<size>(this->sym_); ssym->set_value(final_val); if (section != NULL) ssym->set_output_section(section); } -// Set the symbol value if the expression yields an absolute value. +// Set the symbol value if the expression yields an absolute value or +// a value relative to DOT_SECTION. void Symbol_assignment::set_if_absolute(Symbol_table* symtab, const Layout* layout, - bool is_dot_available, uint64_t dot_value) + bool is_dot_available, uint64_t dot_value, + Output_section* dot_section) { if (this->sym_ == NULL) return; @@ -1002,8 +1004,9 @@ Symbol_assignment::set_if_absolute(Symbol_table* symtab, const Layout* layout, Output_section* val_section; uint64_t val = this->val_->eval_maybe_dot(symtab, layout, false, is_dot_available, dot_value, - NULL, &val_section, NULL); - if (val_section != NULL) + dot_section, &val_section, NULL, + false); + if (val_section != NULL && val_section != dot_section) return; if (parameters->target().get_size() == 32) @@ -1026,6 +1029,8 @@ Symbol_assignment::set_if_absolute(Symbol_table* symtab, const Layout* layout, } else gold_unreachable(); + if (val_section != NULL) + this->sym_->set_output_section(val_section); } // Print for debugging. @@ -1215,7 +1220,7 @@ Script_options::set_section_addresses(Symbol_table* symtab, Layout* layout) for (Symbol_assignments::iterator p = this->symbol_assignments_.begin(); p != this->symbol_assignments_.end(); ++p) - (*p)->set_if_absolute(symtab, layout, false, 0); + (*p)->set_if_absolute(symtab, layout, false, 0, NULL); return this->script_sections_.set_section_addresses(symtab, layout); } @@ -1530,18 +1535,26 @@ read_input_script(Workqueue* workqueue, Symbol_table* symtab, Layout* layout, return true; } -// Helper function for read_version_script() and -// read_commandline_script(). Processes the given file in the mode -// indicated by first_token and lex_mode. +// Helper function for read_version_script(), read_commandline_script() and +// script_include_directive(). Processes the given file in the mode indicated +// by first_token and lex_mode. static bool read_script_file(const char* filename, Command_line* cmdline, Script_options* script_options, int first_token, Lex::Mode lex_mode) { - // TODO: if filename is a relative filename, search for it manually - // using "." + cmdline->options()->search_path() -- not dirsearch. Dirsearch dirsearch; + std::string name = filename; + + // If filename is a relative filename, search for it manually using "." + + // cmdline->options()->library_path() -- not dirsearch. + if (!IS_ABSOLUTE_PATH(filename)) + { + const General_options::Dir_list& search_path = + cmdline->options().library_path(); + name = Dirsearch::find_file_in_dir_list(name, search_path, "."); + } // The file locking code wants to record a Task, but we haven't // started the workqueue yet. This is only for debugging purposes, @@ -1552,7 +1565,7 @@ read_script_file(const char* filename, Command_line* cmdline, Position_dependent_options posdep = cmdline->position_dependent_options(); if (posdep.format_enum() == General_options::OBJECT_FORMAT_BINARY) posdep.set_format_enum(General_options::OBJECT_FORMAT_ELF); - Input_file_argument input_argument(filename, + Input_file_argument input_argument(name.c_str(), Input_file_argument::INPUT_FILE_TYPE_FILE, "", false, posdep); Input_file input_file(&input_argument); @@ -3346,10 +3359,13 @@ script_parse_memory_attr(void* closurev, const char* attrs, size_t attrlen, } extern "C" void -script_include_directive(void* closurev, const char*, size_t) +script_include_directive(void* closurev, const char* filename, size_t length) { - // FIXME: Implement ? - yyerror (closurev, _("GOLD does not currently support INCLUDE directives")); + Parser_closure* closure = static_cast<Parser_closure*>(closurev); + std::string name(filename, length); + Command_line* cmdline = closure->command_line(); + read_script_file(name.c_str(), cmdline, &cmdline->script_options(), + PARSING_LINKER_SCRIPT, Lex::LINKER_SCRIPT); } // Functions for memory regions. |