diff options
author | Ian Lance Taylor <ian@airs.com> | 2010-08-02 13:34:33 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2010-08-02 13:34:33 +0000 |
commit | 88a4108bde4d02cccd632048b45458e84bc8b40b (patch) | |
tree | e020b29ea8793617ea774963998d2de40cd349fe /gold/archive.cc | |
parent | 93d90f466b0a6faa6a7811187139f66a2b9c9c74 (diff) | |
download | gdb-88a4108bde4d02cccd632048b45458e84bc8b40b.zip gdb-88a4108bde4d02cccd632048b45458e84bc8b40b.tar.gz gdb-88a4108bde4d02cccd632048b45458e84bc8b40b.tar.bz2 |
PR 11855
* script.cc (Script_options::Script_options): Initialize
symbol_definitions_ and symbol_references_.
(Script_options::add_symbol_assignment): Update
symbol_definitions_ and symbol_references_.
(Script_options::add_symbol_reference): New function.
(script_symbol): New function.
* script.h (class Script_options): Add symbol_definitions_ and
symbol_references_ fields.
(Script_options::referenced_const_iterator): New type.
(Script_options::referenced_begin): New function.
(Script_options::referenced_end): New function.
(Script_options::is_referenced): New function.
(Script_options::any_unreferenced): New function.
* script-c.h (script_symbol): Declare.
* yyscript.y (exp): Call script_symbol.
* symtab.cc: Include "script.h".
(Symbol_table::gc_mark_undef_symbols): Add layout parameter.
Change all callers. Check symbols referenced by scripts.
(Symbol_table::add_undefined_symbols_from_command_line): Add
layout parameter. Change all callers.
(Symbol_table::do_add_undefined_symbols_from_command_line):
Likewise. Break out loop body. Check symbols referenced by
scripts.
(Symbol_table::add_undefined_symbol_from_command_line): New
function broken out of
do_add_undefined_symbols_from_command_line.
* symtab.h (class Symbol_table): Update declarations.
* archive.cc: Include "layout.h".
(Archive::should_include_member): Add layout parameter. Change
all callers. Check for symbol mentioned in expression.
* archive.h (class Archive): Update declaration.
* object.cc (Sized_relobj::do_should_include_member): Add layout
parameter.
* object.h (Object::should_include_member): Add layout parameter.
Change all callers.
(Object::do_should_include_member): Add layout parameter.
(class Sized_relobj): Update declaration.
* dynobj.cc (Sized_dynobj::do_should_include_member): Add layout
parameter.
* dynobj.h (class Sized_dynobj): Update declaration.
* plugin.cc (Sized_pluginobj::do_should_include_member): Add
layout parameter.
* plugin.h (class Sized_pluginobj): Update declaration.
Diffstat (limited to 'gold/archive.cc')
-rw-r--r-- | gold/archive.cc | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/gold/archive.cc b/gold/archive.cc index 202fc2c8e..f1000a1 100644 --- a/gold/archive.cc +++ b/gold/archive.cc @@ -36,6 +36,7 @@ #include "readsyms.h" #include "symtab.h" #include "object.h" +#include "layout.h" #include "archive.h" #include "plugin.h" @@ -603,8 +604,9 @@ Archive::read_symbols(off_t off) } Archive::Should_include -Archive::should_include_member(Symbol_table* symtab, const char* sym_name, - Symbol** symp, std::string* why, char** tmpbufp, +Archive::should_include_member(Symbol_table* symtab, Layout* layout, + const char* sym_name, Symbol** symp, + std::string* why, char** tmpbufp, size_t* tmpbuflen) { // In an object file, and therefore in an archive map, an @@ -648,13 +650,22 @@ Archive::should_include_member(Symbol_table* symtab, const char* sym_name, if (sym == NULL) { // Check whether the symbol was named in a -u option. - if (!parameters->options().is_undefined(sym_name)) - return Archive::SHOULD_INCLUDE_UNKNOWN; - else + if (parameters->options().is_undefined(sym_name)) { *why = "-u "; *why += sym_name; } + else if (layout->script_options()->is_referenced(sym_name)) + { + size_t alc = 100 + strlen(sym_name); + char* buf = new char[alc]; + snprintf(buf, alc, _("script or expression reference to %s"), + sym_name); + *why = buf; + delete[] buf; + } + else + return Archive::SHOULD_INCLUDE_UNKNOWN; } else if (!sym->is_undefined()) return Archive::SHOULD_INCLUDE_NO; @@ -726,8 +737,8 @@ Archive::add_symbols(Symbol_table* symtab, Layout* layout, Symbol* sym; std::string why; Archive::Should_include t = - Archive::should_include_member(symtab, sym_name, &sym, &why, - &tmpbuf, &tmpbuflen); + Archive::should_include_member(symtab, layout, sym_name, &sym, + &why, &tmpbuf, &tmpbuflen); if (t == Archive::SHOULD_INCLUDE_NO || t == Archive::SHOULD_INCLUDE_YES) @@ -1015,6 +1026,7 @@ Lib_group::add_symbols(Symbol_table* symtab, Layout* layout, && (member.sd_ == NULL || member.sd_->symbol_names != NULL)) { Archive::Should_include t = obj->should_include_member(symtab, + layout, member.sd_, &why); |