+ // the token. If the object is a member of a lib group, however,
+ // the token was already added to the list of locks for the task,
+ // and it will be unblocked automatically at the end of the task.
+ if (!this->do_read_symbols(workqueue) && this->member_ == NULL)
+ workqueue->queue_soon(new Unblock_token(this->this_blocker_,
+ this->next_blocker_));
+}
+
+// Handle a whole lib group. Other than collecting statistics, this just
+// mimics what we do for regular object files in the command line.
+
+bool
+Read_symbols::do_whole_lib_group(Workqueue* workqueue)
+{
+ const Input_file_lib* lib_group = this->input_argument_->lib();
+
+ ++Lib_group::total_lib_groups;
+
+ Task_token* this_blocker = this->this_blocker_;
+ for (Input_file_lib::const_iterator i = lib_group->begin();
+ i != lib_group->end();
+ ++i)
+ {
+ ++Lib_group::total_members;
+ ++Lib_group::total_members_loaded;
+
+ const Input_argument* arg = &*i;
+
+ Task_token* next_blocker;
+ if (i != lib_group->end() - 1)
+ {
+ next_blocker = new Task_token(true);
+ next_blocker->add_blocker();
+ }
+ else
+ next_blocker = this->next_blocker_;
+
+ workqueue->queue_soon(new Read_symbols(this->input_objects_,
+ this->symtab_, this->layout_,
+ this->dirpath_, this->dirindex_,
+ this->mapfile_, arg, NULL,
+ NULL, this_blocker, next_blocker));
+ this_blocker = next_blocker;
+ }
+
+ return true;
+}
+
+// Handle a lib group. We set Read_symbols Tasks as usual, but have them
+// just record the symbol data instead of adding the objects. We also start
+// a Add_lib_group_symbols Task which runs after we've read all the symbols.
+// In that task we process the members in a loop until we are done.
+
+bool
+Read_symbols::do_lib_group(Workqueue* workqueue)
+{
+ const Input_file_lib* lib_group = this->input_argument_->lib();
+
+ if (lib_group->options().whole_archive())
+ return this->do_whole_lib_group(workqueue);
+
+ Lib_group* lib = new Lib_group(lib_group, this);
+
+ Add_lib_group_symbols* add_lib_group_symbols =
+ new Add_lib_group_symbols(this->symtab_, this->layout_,
+ this->input_objects_,
+ lib, this->next_blocker_);
+
+
+ Task_token* next_blocker = new Task_token(true);
+ int j = 0;
+ for (Input_file_lib::const_iterator i = lib_group->begin();
+ i != lib_group->end();
+ ++i, ++j)
+ {
+ const Input_argument* arg = &*i;
+ Archive_member* m = lib->get_member(j);
+
+ next_blocker->add_blocker();
+
+ // Since this Read_symbols will not create an Add_symbols,
+ // just pass NULL as this_blocker.
+ workqueue->queue_soon(new Read_symbols(this->input_objects_,
+ this->symtab_, this->layout_,
+ this->dirpath_, this->dirindex_,
+ this->mapfile_, arg, NULL,
+ m, NULL, next_blocker));
+ }
+
+ add_lib_group_symbols->set_blocker(next_blocker, this->this_blocker_);
+ workqueue->queue_soon(add_lib_group_symbols);
+
+ return true;