aboutsummaryrefslogtreecommitdiff
path: root/gold/script.h
diff options
context:
space:
mode:
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.