aboutsummaryrefslogtreecommitdiff
path: root/gold/script.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2010-08-02 13:34:33 +0000
committerIan Lance Taylor <ian@airs.com>2010-08-02 13:34:33 +0000
commit88a4108bde4d02cccd632048b45458e84bc8b40b (patch)
treee020b29ea8793617ea774963998d2de40cd349fe /gold/script.h
parent93d90f466b0a6faa6a7811187139f66a2b9c9c74 (diff)
downloadgdb-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/script.h')
-rw-r--r--gold/script.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/gold/script.h b/gold/script.h
index 3b8cb92..70e3a59 100644
--- a/gold/script.h
+++ b/gold/script.h
@@ -423,6 +423,10 @@ class Script_options
add_symbol_assignment(const char* name, size_t length, bool is_defsym,
Expression* value, bool provide, bool hidden);
+ // Add a reference to a symbol.
+ void
+ add_symbol_reference(const char* name, size_t length);
+
// Add an assertion.
void
add_assertion(Expression* check, const char* message, size_t messagelen);
@@ -439,6 +443,32 @@ class Script_options
void
add_symbols_to_table(Symbol_table*);
+ // Used to iterate over symbols which are referenced in expressions
+ // but not defined.
+ typedef Unordered_set<std::string>::const_iterator referenced_const_iterator;
+
+ referenced_const_iterator
+ referenced_begin() const
+ { return this->symbol_references_.begin(); }
+
+ referenced_const_iterator
+ referenced_end() const
+ { return this->symbol_references_.end(); }
+
+ // Return whether a symbol is referenced but not defined.
+ bool
+ is_referenced(const std::string& name) const
+ {
+ return (this->symbol_references_.find(name)
+ != this->symbol_references_.end());
+ }
+
+ // Return whether there are any symbols which were referenced but
+ // not defined.
+ bool
+ any_unreferenced() const
+ { return !this->symbol_references_.empty(); }
+
// Finalize the symbol values. Also check assertions.
void
finalize_symbols(Symbol_table*, const Layout*);
@@ -497,6 +527,10 @@ class Script_options
std::string entry_;
// Symbols to set.
Symbol_assignments symbol_assignments_;
+ // Symbols defined in an expression, for faster lookup.
+ Unordered_set<std::string> symbol_definitions_;
+ // Symbols referenced in an expression.
+ Unordered_set<std::string> symbol_references_;
// Assertions to check.
Assertions assertions_;
// Version information parsed from a version script.