aboutsummaryrefslogtreecommitdiff
path: root/gold/script.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2009-12-30 22:35:49 +0000
committerIan Lance Taylor <ian@airs.com>2009-12-30 22:35:49 +0000
commit6affe781e430bbf2075faf6539fb020564b3a38f (patch)
tree692719941fd882684f44cd343d474bd89fec941e /gold/script.h
parentd35130122459b29ac7f41123d224aa61d00625f6 (diff)
downloadgdb-6affe781e430bbf2075faf6539fb020564b3a38f.zip
gdb-6affe781e430bbf2075faf6539fb020564b3a38f.tar.gz
gdb-6affe781e430bbf2075faf6539fb020564b3a38f.tar.bz2
PR 10861
* script.h (class Version_script_info): Define Language enum. Update declarations. Define Glob, Exact, and Lookup types. Add new fields globals_, locals_, and is_finalized_. * script.cc: Various formatting fixes. (class Parser_closure): Change language_stack_ from a vector of std::string to one of Version_script_info::Language. Adjust all uses accordingly. (class Lazy_demangler): Remove. (struct Version_expression): Change language from std::string to Version_script_info::Language. (Version_script_info::Version_script_info): New function. (Version_script_info::~Version_script_info): Don't call clear. (Version_script_info::finalize): New function. (Version_script_info::build_lookup_tables): New function. (Version_script_info::build_expression_list_lookup): New function. (Version_script_info::get_symbol_version_helper): Rewrite to use lookup tables. (Version_script_info::print_expression_list): Adjust to use Version_script_info::Language. (script_push_lex_into_version_mode): Check that the version script has not been finalized. (version_script_push_lang): Change language string to Version_script_info::Language. * options.cc (Command_line::version_script): New function. * options.h (class General_options): Add finalize_dynamic_list function. Change version_script from declaration to definition. * testsuite/ver_test_4.script: Remove duplicate def of t2_2. * testsuite/version_script.map: Remove duplicate def of foo. * testsuite/Makefile.am (ver_matching_def.so): Depend upon version_script.map. * testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold/script.h')
-rw-r--r--gold/script.h83
1 files changed, 75 insertions, 8 deletions
diff --git a/gold/script.h b/gold/script.h
index 7129565..a7e0186 100644
--- a/gold/script.h
+++ b/gold/script.h
@@ -128,12 +128,32 @@ class Expression
class Version_script_info
{
public:
+ // The languages which can be specified in a versionn script.
+ enum Language
+ {
+ LANGUAGE_C, // No demangling.
+ LANGUAGE_CXX, // C++ demangling.
+ LANGUAGE_JAVA, // Java demangling.
+ LANGUAGE_COUNT
+ };
+
+ Version_script_info();
+
~Version_script_info();
// Clear everything.
void
clear();
+ // Finalize the version control information.
+ void
+ finalize();
+
+ // Return whether the information is finalized.
+ bool
+ is_finalized() const
+ { return this->is_finalized_; }
+
// Return whether any version were defined in the version script.
bool
empty() const
@@ -152,8 +172,6 @@ class Version_script_info
{ return this->get_symbol_version_helper(symbol, false, NULL); }
// Return the names of versions defined in the version script.
- // Strings are allocated out of the stringpool given in the
- // constructor.
std::vector<std::string>
get_versions() const;
@@ -174,6 +192,10 @@ class Version_script_info
struct Version_tree*
allocate_version_tree();
+ // Build the lookup tables after all data have been read.
+ void
+ build_lookup_tables();
+
// Print contents to the FILE. This is for debugging.
void
print(FILE*) const;
@@ -182,13 +204,58 @@ class Version_script_info
void
print_expression_list(FILE* f, const Version_expression_list*) const;
- bool get_symbol_version_helper(const char* symbol,
- bool check_global,
- std::string* pversion) const;
+ bool
+ get_symbol_version_helper(const char* symbol,
+ bool check_global,
+ std::string* pversion) const;
+
+ // Fast lookup information for a glob pattern.
+ struct Glob
+ {
+ Glob()
+ : pattern(NULL), version(NULL)
+ { }
+
+ Glob(const char* p, const Version_tree* v)
+ : pattern(p), version(v)
+ { }
+
+ // A pointer to the glob pattern. The pattern itself lives in a
+ // Version_expression structure.
+ const char* pattern;
+ // The Version_tree we use if this pattern matches.
+ const Version_tree* version;
+ };
+
+ // Fast lookup information for a given language.
+
+ typedef Unordered_map<std::string, const Version_tree*> Exact;
+
+ struct Lookup
+ {
+ // A hash table of all exact match strings mapping to a
+ // Version_tree.
+ Exact exact;
+ // A vector of glob patterns mapping to Version_trees.
+ std::vector<Glob> globs;
+ };
- std::vector<struct Version_dependency_list*> dependency_lists_;
- std::vector<struct Version_expression_list*> expression_lists_;
- std::vector<struct Version_tree*> version_trees_;
+ void
+ build_expression_list_lookup(const Version_expression_list*,
+ const Version_tree*, Lookup**);
+
+ // All the version dependencies we allocate.
+ std::vector<Version_dependency_list*> dependency_lists_;
+ // All the version expressions we allocate.
+ std::vector<Version_expression_list*> expression_lists_;
+ // The list of versions.
+ std::vector<Version_tree*> version_trees_;
+ // Lookup information for global symbols, by language.
+ Lookup* globals_[LANGUAGE_COUNT];
+ // Lookup information for local symbols, by language.
+ Lookup* locals_[LANGUAGE_COUNT];
+ // Whether this has been finalized.
+ bool is_finalized_;
};
// This class manages assignments to symbols. These can appear in