+ if (bytes >= Archive::sarmag)
+ {
+ if (memcmp(p, Archive::armag, Archive::sarmag) == 0)
+ {
+ // This is an archive.
+ Archive* arch = new Archive(this->input_argument_->file().name(),
+ input_file);
+ arch->setup();
+ workqueue->queue(new Add_archive_symbols(this->options_,
+ this->symtab_,
+ this->layout_,
+ this->input_objects_,
+ arch,
+ this->input_group_,
+ this->this_blocker_,
+ this->next_blocker_));
+ return;
+ }
+ }
+
+ if (bytes == 0)
+ {
+ fprintf(stderr, _("%s: %s: file is empty\n"),
+ program_name, input_file->file().filename().c_str());
+ gold_exit(false);
+ }
+
+ // Try to parse this file as a script.
+ if (read_input_script(workqueue, this->options_, this->symtab_,
+ this->layout_, this->dirpath_, this->input_objects_,
+ this->input_group_, this->input_argument_, input_file,
+ p, bytes, this->this_blocker_, this->next_blocker_))
+ return;
+
+ // Here we have to handle any other input file types we need.
+ fprintf(stderr, _("%s: %s: not an object or archive\n"),
+ program_name, input_file->file().filename().c_str());
+ gold_exit(false);
+}
+
+// Handle a group. We need to walk through the arguments over and
+// over until we don't see any new undefined symbols. We do this by
+// setting off Read_symbols Tasks as usual, but recording the archive
+// entries instead of deleting them. We also start a Finish_group
+// Task which runs after we've read all the symbols. In that task we
+// process the archives in a loop until we are done.
+
+void
+Read_symbols::do_group(Workqueue* workqueue)
+{
+ Input_group* input_group = new Input_group();
+
+ const Input_file_group* group = this->input_argument_->group();
+ Task_token* this_blocker = this->this_blocker_;
+ for (Input_file_group::const_iterator p = group->begin();
+ p != group->end();
+ ++p)
+ {
+ const Input_argument* arg = &*p;
+ gold_assert(arg->is_file());
+
+ Task_token* next_blocker = new Task_token();
+ next_blocker->add_blocker();
+ workqueue->queue(new Read_symbols(this->options_, this->input_objects_,
+ this->symtab_, this->layout_,
+ this->dirpath_, arg, input_group,
+ this_blocker, next_blocker));
+ this_blocker = next_blocker;
+ }
+
+ const int saw_undefined = this->symtab_->saw_undefined();
+ workqueue->queue(new Finish_group(this->options_,
+ this->input_objects_,
+ this->symtab_,
+ this->layout_,
+ input_group,
+ saw_undefined,
+ this_blocker,
+ this->next_blocker_));