class Layout;
class Mapfile;
class Input_argument;
+class Input_arguments;
class Input_objects;
class Input_group;
class Input_file;
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
{ 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;
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;
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
class Symbol_assignment
{
public:
- Symbol_assignment(const char* name, size_t namelen, Expression* val,
- bool provide, bool hidden)
- : name_(name, namelen), val_(val), provide_(provide), hidden_(hidden),
- sym_(NULL)
+ Symbol_assignment(const char* name, size_t namelen, bool is_defsym,
+ Expression* val, bool provide, bool hidden)
+ : name_(name, namelen), val_(val), is_defsym_(is_defsym),
+ provide_(provide), hidden_(hidden), sym_(NULL)
{ }
// Add the symbol to the symbol table.
std::string name_;
// Expression to assign to symbol.
Expression* val_;
+ // True if this symbol is defined by a --defsym, false if it is
+ // defined in a linker script.
+ bool is_defsym_;
// Whether the assignment should be provided (only set if there is
// an undefined reference to the symbol.
bool provide_;
// Add a symbol to be defined.
void
- add_symbol_assignment(const char* name, size_t length, Expression* value,
- bool provide, bool hidden);
+ add_symbol_assignment(const char* name, size_t length, bool is_defsym,
+ Expression* value, bool provide, bool hidden);
// Add an assertion.
void
Script_sections script_sections_;
};
+// Information about a script input that will persist during the whole linker
+// run. Needed only during an incremental build to retrieve the input files
+// added by this script.
+
+class Script_info
+{
+ public:
+ Script_info(Input_arguments* inputs)
+ : inputs_(inputs)
+ { }
+
+ // Returns the input files included because of this script.
+ Input_arguments*
+ inputs()
+ { return this->inputs_; }
+
+ private:
+ Input_arguments* inputs_;
+};
+
// FILE was found as an argument on the command line, but was not
// recognized as an ELF file. Try to read it as a script. Return
// true if the file was handled. This has to handle /usr/lib/libc.so
// whether the function took over NEXT_BLOCKER.
bool
-read_input_script(Workqueue*, const General_options&, Symbol_table*, Layout*,
- Dirsearch*, Input_objects*, Mapfile*, Input_group*,
+read_input_script(Workqueue*, Symbol_table*, Layout*, Dirsearch*, int,
+ Input_objects*, Mapfile*, Input_group*,
const Input_argument*, Input_file*,
Task_token* next_blocker, bool* used_next_blocker);
// Read it as a script, and execute its contents immediately.
bool
-read_commandline_script(const char* filename, Command_line*);
+read_commandline_script(const char* filename, Command_line* cmdline);
// FILE was found as an argument to --version-script. Read it as a
// version script, and store its contents in
bool
read_version_script(const char* filename, Command_line* cmdline);
+// FILENAME was found as an argument to --dynamic-list. Read it as a
+// version script (actually, a versym_node from a version script), and
+// store its contents in DYNAMIC_LIST.
+
+bool
+read_dynamic_list(const char* filename, Command_line* cmdline,
+ Script_options* dynamic_list);
+
} // End namespace gold.
#endif // !defined(GOLD_SCRIPT_H)