diff options
author | Cary Coutant <ccoutant@google.com> | 2011-03-30 01:31:57 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2011-03-30 01:31:57 +0000 |
commit | e0c5278066dc16f8b0e00e970f56c1bd4d32f864 (patch) | |
tree | ba7ae7374a9b99a360917e9b7eefce05da11a0e8 /gold/incremental.cc | |
parent | 53a9226b8f0df0be4f8af3478212741eff1a489c (diff) | |
download | gdb-e0c5278066dc16f8b0e00e970f56c1bd4d32f864.zip gdb-e0c5278066dc16f8b0e00e970f56c1bd4d32f864.tar.gz gdb-e0c5278066dc16f8b0e00e970f56c1bd4d32f864.tar.bz2 |
* archive.cc (Library_base::should_include_member): Move
method here from class Archive.
(Archive::Archive): Initialize base class.
(Archive::should_include_member): Move to base class.
(Archive::do_for_all_unused_symbols): New function.
(Add_archive_symbols::run): Remove redundant access to
incremental_inputs.
(Lib_group::Lib_group): Initialize base class.
(Lib_group::do_filename): New function.
(Lib_group::include_member): Pass pointer to Lib_group to
report_object.
(Lib_group::do_for_all_unused_symbols): New function.
(Add_lib_group_symbols::run): Report archive information for
incremental links.
* archive.h (class Library_base): New base class.
(class Archive): Derive from Library_base.
(Archive::filename): Move to base class.
(Archive::set_incremental_info): Likewise.
(Archive::incremental_info): Likewise.
(Archive::Should_include): Likewise.
(Archive::should_include_member): Likewise.
(Archive::Armap_entry): Remove.
(Archive::Unused_symbol_iterator): Remove.
(Archive::unused_symbols_begin): Remove.
(Archive::unused_symbols_end): Remove.
(Archive::do_filename): New function.
(Archive::do_get_mtime): New function.
(Archive::do_for_all_unused_symbols): New function.
(Archive::task_): Move to base class.
(Archive::incremental_info_): Likewise.
(class Lib_group): Derive from Library_base.
(Lib_group::do_filename): New function.
(Lib_group::do_get_mtime): New function.
(Lib_group::do_for_all_unused_symbols): New function.
(Lib_group::task_): Move to base class.
* dynobj.cc (Sized_dynobj::do_for_all_global_symbols): New
function.
* dynobj.h (Sized_dynobj::do_for_all_global_symbols): New
function.
* incremental.cc (Incremental_inputs::report_archive_begin):
Use Library_base; call library's get_mtime; add incremental inputs
entry before members.
(class Unused_symbol_visitor): New class.
(Incremental_inputs::report_archive_end): Use Library_base; use
visitor class to record unused symbols; don't add incremental inputs
entry after members.
(Incremental_inputs::report_object): Use Library_base.
* incremental.h
(Incremental_archive_entry::Incremental_archive_entry): Remove
unused Archive parameter.
(Incremental_inputs::report_archive_begin): Use Library_base.
(Incremental_inputs::report_archive_end): Likewise.
(Incremental_inputs::report_object): Likewise.
* object.cc (Sized_relobj::do_for_all_global_symbols): New
function.
* object.h (Object::for_all_global_symbols): New function.
(Object::do_for_all_global_symbols): New function.
(Sized_relobj::do_for_all_global_symbols): New function.
* plugin.cc (Sized_pluginobj::do_for_all_global_symbols): New
function.
* plugin.h (Sized_pluginobj::do_for_all_global_symbols): New
function.
Diffstat (limited to 'gold/incremental.cc')
-rw-r--r-- | gold/incremental.cc | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/gold/incremental.cc b/gold/incremental.cc index aa9d7d3..f7edf04 100644 --- a/gold/incremental.cc +++ b/gold/incremental.cc @@ -436,38 +436,59 @@ Incremental_inputs::report_command_line(int argc, const char* const* argv) // input objects until report_archive_end is called. void -Incremental_inputs::report_archive_begin(Archive* arch) +Incremental_inputs::report_archive_begin(Library_base* arch) { Stringpool::Key filename_key; - Timespec mtime = arch->file().get_mtime(); + Timespec mtime = arch->get_mtime(); this->strtab_->add(arch->filename().c_str(), false, &filename_key); Incremental_archive_entry* entry = - new Incremental_archive_entry(filename_key, arch, mtime); + new Incremental_archive_entry(filename_key, mtime); arch->set_incremental_info(entry); + this->inputs_.push_back(entry); } +// Visitor class for processing the unused global symbols in a library. +// An instance of this class is passed to the library's +// for_all_unused_symbols() iterator, which will call the visit() +// function for each global symbol defined in each unused library +// member. We add those symbol names to the incremental info for the +// library. + +class Unused_symbol_visitor : public Library_base::Symbol_visitor_base +{ + public: + Unused_symbol_visitor(Incremental_archive_entry* entry, Stringpool* strtab) + : entry_(entry), strtab_(strtab) + { } + + void + visit(const char* sym) + { + Stringpool::Key symbol_key; + this->strtab_->add(sym, true, &symbol_key); + this->entry_->add_unused_global_symbol(symbol_key); + } + + private: + Incremental_archive_entry* entry_; + Stringpool* strtab_; +}; + // Finish recording the input archive file ARCHIVE. This is called by the // Add_archive_symbols task after determining which archive members // to include. void -Incremental_inputs::report_archive_end(Archive* arch) +Incremental_inputs::report_archive_end(Library_base* arch) { Incremental_archive_entry* entry = arch->incremental_info(); gold_assert(entry != NULL); // Collect unused global symbols. - for (Archive::Unused_symbol_iterator p = arch->unused_symbols_begin(); - p != arch->unused_symbols_end(); - ++p) - { - Stringpool::Key symbol_key; - this->strtab_->add(*p, true, &symbol_key); - entry->add_unused_global_symbol(symbol_key); - } - this->inputs_.push_back(entry); + Unused_symbol_visitor v(entry, this->strtab_); + arch->for_all_unused_symbols(&v); } // Record the input object file OBJ. If ARCH is not NULL, attach @@ -475,7 +496,7 @@ Incremental_inputs::report_archive_end(Archive* arch) // Add_symbols task after finding out the type of the file. void -Incremental_inputs::report_object(Object* obj, Archive* arch) +Incremental_inputs::report_object(Object* obj, Library_base* arch) { Stringpool::Key filename_key; Timespec mtime = obj->input_file()->file().get_mtime(); |