- if (bin_dummy_emulation.ar_replace)
- return bin_dummy_emulation.ar_replace (after_bfd, file_name, verbose);
+ /* When flattening, add the members of an archive instead of the
+ archive itself. */
+ if (flatten && bfd_check_format (new_bfd, bfd_archive))
+ {
+ bfd *elt;
+ bfd_boolean added = FALSE;
+
+ for (elt = bfd_openr_next_archived_file (new_bfd, NULL);
+ elt;
+ elt = bfd_openr_next_archived_file (new_bfd, elt))
+ {
+ if (do_ar_emul_append (after_bfd, elt, verbose, TRUE, check))
+ {
+ added = TRUE;
+ after_bfd = &((*after_bfd)->archive_next);
+ }
+ }
+
+ return added;
+ }