aboutsummaryrefslogtreecommitdiff
path: root/gold/incremental.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gold/incremental.cc')
-rw-r--r--gold/incremental.cc49
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();