+// This class represents the files surrounded by a --start-lib ... --end-lib.
+
+class Lib_group : public Library_base
+{
+ public:
+ Lib_group(const Input_file_lib* lib, Task* task);
+
+ // Select members from the lib group as needed and add them to the link.
+ void
+ add_symbols(Symbol_table*, Layout*, Input_objects*);
+
+ // Include a member of the lib group in the link.
+ void
+ include_member(Symbol_table*, Layout*, Input_objects*, const Archive_member&);
+
+ Archive_member*
+ get_member(int i)
+ {
+ return &this->members_[i];
+ }
+
+ // Total number of archives seen.
+ static unsigned int total_lib_groups;
+ // Total number of archive members seen.
+ static unsigned int total_members;
+ // Number of archive members loaded.
+ static unsigned int total_members_loaded;
+
+ // Dump statistical information to stderr.
+ static void
+ print_stats();
+
+ private:
+ // The file name.
+ const std::string&
+ do_filename() const;
+
+ // A Lib_group does not have a modification time, since there is no
+ // real library file.
+ Timespec
+ do_get_mtime()
+ { return Timespec(0, 0); }
+
+ // Iterator for unused global symbols in the library.
+ void
+ do_for_all_unused_symbols(Symbol_visitor_base*) const;
+
+ // For reading the files.
+ const Input_file_lib* lib_;
+ // Table of the objects in the group.
+ std::vector<Archive_member> members_;
+};
+
+// This class is used to pick out the desired elements and add them to the link.
+
+class Add_lib_group_symbols : public Task
+{
+ public:
+ Add_lib_group_symbols(Symbol_table* symtab, Layout* layout,
+ Input_objects* input_objects,
+ Lib_group* lib, Task_token* next_blocker)
+ : symtab_(symtab), layout_(layout), input_objects_(input_objects),
+ lib_(lib), readsyms_blocker_(NULL), this_blocker_(NULL),
+ next_blocker_(next_blocker)
+ { }
+
+ ~Add_lib_group_symbols();
+
+ // The standard Task methods.
+
+ Task_token*
+ is_runnable();
+
+ void
+ locks(Task_locker*);
+
+ void
+ run(Workqueue*);
+
+ // Set the blocker to use for this task.
+ void
+ set_blocker(Task_token* readsyms_blocker, Task_token* this_blocker)
+ {
+ gold_assert(this->readsyms_blocker_ == NULL && this->this_blocker_ == NULL);
+ this->readsyms_blocker_ = readsyms_blocker;
+ this->this_blocker_ = this_blocker;
+ }
+
+ std::string
+ get_name() const
+ {
+ return "Add_lib_group_symbols";
+ }
+
+ private:
+ Symbol_table* symtab_;
+ Layout* layout_;
+ Input_objects* input_objects_;
+ Lib_group* lib_;
+ Task_token* readsyms_blocker_;
+ Task_token* this_blocker_;
+ Task_token* next_blocker_;
+};
+