1 /* ar.c - Archive modify and extract.
2 Copyright 1991, 92, 93, 94, 95, 96, 97, 98, 1999
3 Free Software Foundation, Inc.
5 This file is part of GNU Binutils.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 Bugs: should use getopt the way tar does (complete w/optional -) and
23 should have long options too. GNU ar used to check file against filesystem
24 in quick_update and replace operations (would check mtime). Doesn't warn
25 when name truncated. No way to specify pos_end. Error messages should be
29 #include "libiberty.h"
38 #define EXT_NAME_LEN 3 /* bufflen of addition to name if it's MS-DOS */
40 #define EXT_NAME_LEN 6 /* ditto for *NIX */
45 /* Kludge declaration from BFD! This is ugly! FIXME! XXX */
48 bfd_special_undocumented_glue PARAMS ((bfd * abfd, const char *filename));
50 /* Static declarations */
53 mri_emul PARAMS ((void));
56 normalize PARAMS ((const char *, bfd *));
59 remove_output PARAMS ((void));
62 map_over_members PARAMS ((bfd *, void (*)(bfd *), char **, int));
65 print_contents PARAMS ((bfd * member));
68 delete_members PARAMS ((bfd *, char **files_to_delete));
72 do_quick_append PARAMS ((const char *archive_filename,
73 char **files_to_append));
77 move_members PARAMS ((bfd *, char **files_to_move));
80 replace_members PARAMS ((bfd *, char **files_to_replace, boolean quick));
83 print_descr PARAMS ((bfd * abfd));
86 write_archive PARAMS ((bfd *));
89 ranlib_only PARAMS ((const char *archname));
92 ranlib_touch PARAMS ((const char *archname));
97 /** Globals and flags */
101 /* This flag distinguishes between ar and ranlib:
102 1 means this is 'ranlib'; 0 means this is 'ar'.
103 -1 means if we should use argv[0] to decide. */
104 extern int is_ranlib;
106 /* Nonzero means don't warn about creating the archive file if necessary. */
107 int silent_create = 0;
109 /* Nonzero means describe each action performed. */
112 /* Nonzero means preserve dates of members when extracting them. */
113 int preserve_dates = 0;
115 /* Nonzero means don't replace existing members whose dates are more recent
116 than the corresponding files. */
119 /* Controls the writing of an archive symbol table (in BSD: a __.SYMDEF
120 member). -1 means we've been explicitly asked to not write a symbol table;
121 +1 means we've been explictly asked to write it;
123 Traditionally, the default in BSD has been to not write the table.
124 However, for POSIX.2 compliance the default is now to write a symbol table
125 if any of the members are object files. */
128 /* Nonzero means it's the name of an existing member; position new or moved
129 files with respect to this one. */
130 char *posname = NULL;
132 /* Sez how to use `posname': pos_before means position before that member.
133 pos_after means position after that member. pos_end means always at end.
134 pos_default means default appropriately. For the latter two, `posname'
135 should also be zero. */
138 pos_default, pos_before, pos_after, pos_end
139 } postype = pos_default;
142 get_pos_bfd PARAMS ((bfd **, enum pos, const char *));
144 /* Whether to truncate names of files stored in the archive. */
145 static boolean ar_truncate = false;
152 interactive = isatty (fileno (stdin));
156 /* If COUNT is 0, then FUNCTION is called once on each entry. If nonzero,
157 COUNT is the length of the FILES chain; FUNCTION is called on each entry
158 whose name matches one in FILES. */
161 map_over_members (arch, function, files, count)
163 void (*function) PARAMS ((bfd *));
171 for (head = arch->next; head; head = head->next)
178 /* This may appear to be a baroque way of accomplishing what we want.
179 However we have to iterate over the filenames in order to notice where
180 a filename is requested but does not exist in the archive. Ditto
181 mapping over each file each time -- we want to hack multiple
184 for (; count > 0; files++, count--)
186 boolean found = false;
188 for (head = arch->next; head; head = head->next)
191 if (head->filename == NULL)
193 /* Some archive formats don't get the filenames filled in
194 until the elements are opened. */
196 bfd_stat_arch_elt (head, &buf);
198 if ((head->filename != NULL) &&
199 (!strcmp (*files, head->filename)))
206 /* xgettext:c-format */
207 fprintf (stderr, _("no entry %s in archive\n"), *files);
211 boolean operation_alters_arch = false;
219 s = help ? stdout : stderr;
223 /* xgettext:c-format */
224 fprintf (s, _("Usage: %s [-]{dmpqrstx}[abcilosSuvV] [member-name] archive-file file...\n"), program_name);
225 /* xgettext:c-format */
226 fprintf (s, _(" %s -M [<mri-script]\n"), program_name);
227 fprintf (s, _(" commands:\n"));
228 fprintf (s, _(" d - delete file(s) from the archive\n"));
229 fprintf (s, _(" m[ab] - move file(s) in the archive\n"));
230 fprintf (s, _(" p - print file(s) found in the archive\n"));
231 fprintf (s, _(" q[f] - quick append file(s) to the archive\n"));
232 fprintf (s, _(" r[ab][f][u] - replace existing or insert new file(s) into the archive\n"));
233 fprintf (s, _(" t - display contents of archive\n"));
234 fprintf (s, _(" x[o] - extract file(s) from the archive\n"));
235 fprintf (s, _(" command specific modifiers:\n"));
236 fprintf (s, _(" [a] - put file(s) after [member-name]\n"));
237 fprintf (s, _(" [b] - put file(s) before [member-name] (same as [i])\n"));
238 fprintf (s, _(" [f] - truncate inserted file names\n"));
239 fprintf (s, _(" [o] - preserve original dates\n"));
240 fprintf (s, _(" [u] - only replace files that are newer than current archive contents\n"));
241 fprintf (s, _(" generic modifiers:\n"));
242 fprintf (s, _(" [c] - do not warn if the library had to be created\n"));
243 fprintf (s, _(" [s] - create an archive index (cf. ranlib)\n"));
244 fprintf (s, _(" [S] - do not build a symbol table\n"));
245 fprintf (s, _(" [v] - be verbose\n"));
246 fprintf (s, _(" [V] - display the version number\n"));
249 /* xgettext:c-format */
250 fprintf (s, _("Usage: %s [-vV] archive\n"), program_name);
252 list_supported_targets (program_name, stderr);
255 fprintf (s, _("Report bugs to bug-gnu-utils@gnu.org\n"));
257 xexit (help ? 0 : 1);
260 /* Normalize a file name specified on the command line into a file
261 name which we will use in an archive. */
264 normalize (file, abfd)
268 const char *filename;
270 filename = strrchr (file, '/');
271 if (filename != (char *) NULL)
278 && strlen (filename) > abfd->xvec->ar_max_namelen)
283 s = (char *) xmalloc (abfd->xvec->ar_max_namelen + 1);
284 memcpy (s, filename, abfd->xvec->ar_max_namelen);
285 s[abfd->xvec->ar_max_namelen] = '\0';
292 /* Remove any output file. This is only called via xatexit. */
294 static char *output_filename = NULL;
295 static FILE *output_file = NULL;
296 static bfd *output_bfd = NULL;
301 if (output_filename != NULL)
303 if (output_bfd != NULL && output_bfd->iostream != NULL)
304 fclose ((FILE *) (output_bfd->iostream));
305 if (output_file != NULL)
306 fclose (output_file);
307 unlink (output_filename);
311 /* The option parsing should be in its own function.
312 It will be when I have getopt working. */
323 none = 0, delete, replace, print_table,
324 print_files, extract, move, quick_append
328 char *inarch_filename;
331 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
332 setlocale (LC_MESSAGES, "");
334 bindtextdomain (PACKAGE, LOCALEDIR);
335 textdomain (PACKAGE);
337 program_name = argv[0];
338 xmalloc_set_program_name (program_name);
344 temp = strrchr (program_name, '/');
349 if (strlen (temp) >= 6
350 && strcmp (temp + strlen (temp) - 6, "ranlib") == 0)
356 if (argc > 1 && argv[1][0] == '-')
358 if (strcmp (argv[1], "--help") == 0)
360 else if (strcmp (argv[1], "--version") == 0)
363 print_version ("ranlib");
365 print_version ("ar");
369 START_PROGRESS (program_name, 0);
372 set_default_bfd_target ();
376 xatexit (remove_output);
380 boolean touch = false;
382 if (argc < 2 || strcmp (argv[1], "--help") == 0)
384 if (strcmp (argv[1], "-V") == 0
385 || strcmp (argv[1], "-v") == 0
386 || strncmp (argv[1], "--v", 3) == 0)
387 print_version ("ranlib");
389 if (strcmp (argv[1], "-t") == 0)
394 while (arg_index < argc)
397 ranlib_only (argv[arg_index]);
399 ranlib_touch (argv[arg_index]);
405 if (argc == 2 && strcmp (argv[1], "-M") == 0)
417 ++arg_ptr; /* compatibility */
419 while ((c = *arg_ptr++) != '\0')
430 if (operation != none)
431 fatal (_("two different operation options specified"));
436 operation_alters_arch = true;
440 operation_alters_arch = true;
443 operation = print_files;
446 operation = quick_append;
447 operation_alters_arch = true;
451 operation_alters_arch = true;
454 operation = print_table;
487 postype = pos_before;
490 postype = pos_before;
499 /* xgettext:c-format */
500 fprintf (stderr, _("%s: illegal option -- %c\n"), program_name, c);
506 print_version ("ar");
519 /* We can't write an armap when using ar q, so just do ar r
521 if (operation == quick_append && write_armap)
524 if ((operation == none || operation == print_table)
527 ranlib_only (argv[2]);
531 if (operation == none)
532 fatal (_("no operation specified"));
534 if (newer_only && operation != replace)
535 fatal (_("`u' is only meaningful with the `r' option."));
539 if (postype != pos_default)
540 posname = argv[arg_index++];
542 inarch_filename = argv[arg_index++];
544 files = arg_index < argc ? argv + arg_index : NULL;
547 /* We don't use do_quick_append any more. Too many systems
548 expect ar to always rebuild the symbol table even when q is
551 /* We can't do a quick append if we need to construct an
552 extended name table, because do_quick_append won't be able to
553 rebuild the name table. Unfortunately, at this point we
554 don't actually know the maximum name length permitted by this
555 object file format. So, we guess. FIXME. */
556 if (operation == quick_append && ! ar_truncate)
560 for (chk = files; chk != NULL && *chk != '\0'; chk++)
562 if (strlen (normalize (*chk, (bfd *) NULL)) > 14)
570 if (operation == quick_append)
572 /* Note that quick appending to a non-existent archive creates it,
573 even if there are no files to append. */
574 do_quick_append (inarch_filename, files);
579 arch = open_inarch (inarch_filename,
580 files == NULL ? (char *) NULL : files[0]);
585 map_over_members (arch, print_descr, files, argc - 3);
589 map_over_members (arch, print_contents, files, argc - 3);
593 map_over_members (arch, extract_file, files, argc - 3);
598 delete_members (arch, files);
603 move_members (arch, files);
608 if (files != NULL || write_armap > 0)
609 replace_members (arch, files, operation == quick_append);
612 /* Shouldn't happen! */
614 /* xgettext:c-format */
615 fprintf (stderr, _("%s: internal error -- this option not implemented\n"),
621 END_PROGRESS (program_name);
628 open_inarch (archive_filename, file)
629 const char *archive_filename;
639 bfd_set_error (bfd_error_no_error);
643 if (stat (archive_filename, &sbuf) != 0)
647 /* KLUDGE ALERT! Temporary fix until I figger why
648 * stat() is wrong ... think it's buried in GO32's IDT
652 bfd_fatal (archive_filename);
655 if (!operation_alters_arch)
657 fprintf (stderr, "%s: ", program_name);
658 perror (archive_filename);
663 /* Try to figure out the target to use for the archive from the
664 first object on the list. */
669 obj = bfd_openr (file, NULL);
672 if (bfd_check_format (obj, bfd_object))
673 target = bfd_get_target (obj);
674 (void) bfd_close (obj);
678 /* Create an empty archive. */
679 arch = bfd_openw (archive_filename, target);
681 || ! bfd_set_format (arch, bfd_archive)
682 || ! bfd_close (arch))
683 bfd_fatal (archive_filename);
686 arch = bfd_openr (archive_filename, target);
690 bfd_fatal (archive_filename);
693 if (! bfd_check_format_matches (arch, bfd_archive, &matching))
695 bfd_nonfatal (archive_filename);
696 if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
698 list_matching_formats (matching);
704 last_one = &(arch->next);
705 /* Read all the contents right away, regardless. */
706 for (next_one = bfd_openr_next_archived_file (arch, NULL);
708 next_one = bfd_openr_next_archived_file (arch, next_one))
711 *last_one = next_one;
712 last_one = &next_one->next;
714 *last_one = (bfd *) NULL;
715 if (bfd_get_error () != bfd_error_no_more_archived_files)
721 print_contents (abfd)
725 char *cbuf = xmalloc (BUFSIZE);
728 if (bfd_stat_arch_elt (abfd, &buf) != 0)
729 /* xgettext:c-format */
730 fatal (_("internal stat error on %s"), bfd_get_filename (abfd));
733 /* xgettext:c-format */
734 printf (_("\n<member %s>\n\n"), bfd_get_filename (abfd));
736 bfd_seek (abfd, 0, SEEK_SET);
739 while (ncopied < size)
743 int tocopy = size - ncopied;
744 if (tocopy > BUFSIZE)
747 nread = bfd_read (cbuf, 1, tocopy, abfd); /* oops -- broke
750 /* xgettext:c-format */
751 fatal (_("%s is not a valid archive"),
752 bfd_get_filename (bfd_my_archive (abfd)));
753 fwrite (cbuf, 1, nread, stdout);
759 /* Extract a member of the archive into its own file.
761 We defer opening the new file until after we have read a BUFSIZ chunk of the
762 old one, since we know we have just read the archive header for the old
763 one. Since most members are shorter than BUFSIZ, this means we will read
764 the old header, read the old data, write a new inode for the new file, and
765 write the new data, and be done. This 'optimization' is what comes from
766 sitting next to a bare disk and hearing it every time it seeks. -- Gnu
774 char *cbuf = xmalloc (BUFSIZE);
780 if (bfd_stat_arch_elt (abfd, &buf) != 0)
781 /* xgettext:c-format */
782 fatal (_("internal stat error on %s"), bfd_get_filename (abfd));
786 /* xgettext:c-format */
787 fatal (_("stat returns negative size for %s"), bfd_get_filename (abfd));
790 printf ("x - %s\n", bfd_get_filename (abfd));
792 bfd_seek (abfd, 0, SEEK_SET);
797 /* Seems like an abstraction violation, eh? Well it's OK! */
798 output_filename = bfd_get_filename (abfd);
800 ostream = fopen (bfd_get_filename (abfd), FOPEN_WB);
803 perror (bfd_get_filename (abfd));
807 output_file = ostream;
810 while (ncopied < size)
812 tocopy = size - ncopied;
813 if (tocopy > BUFSIZE)
816 nread = bfd_read (cbuf, 1, tocopy, abfd);
818 /* xgettext:c-format */
819 fatal (_("%s is not a valid archive"),
820 bfd_get_filename (bfd_my_archive (abfd)));
822 /* See comment above; this saves disk arm motion */
825 /* Seems like an abstraction violation, eh? Well it's OK! */
826 output_filename = bfd_get_filename (abfd);
828 ostream = fopen (bfd_get_filename (abfd), FOPEN_WB);
831 perror (bfd_get_filename (abfd));
835 output_file = ostream;
837 fwrite (cbuf, 1, nread, ostream);
845 output_filename = NULL;
847 chmod (bfd_get_filename (abfd), buf.st_mode);
850 set_times (bfd_get_filename (abfd), &buf);
857 /* We don't use this anymore. Too many systems expect ar to rebuild
858 the symbol table even when q is used. */
860 /* Just do it quickly; don't worry about dups, armap, or anything like that */
863 do_quick_append (archive_filename, files_to_append)
864 const char *archive_filename;
865 char **files_to_append;
868 char *buf = xmalloc (BUFSIZE);
869 long tocopy, thistime;
872 boolean newfile = false;
873 bfd_set_error (bfd_error_no_error);
875 if (stat (archive_filename, &sbuf) != 0)
880 /* KLUDGE ALERT! Temporary fix until I figger why
881 * stat() is wrong ... think it's buried in GO32's IDT
886 bfd_fatal (archive_filename);
892 ofile = fopen (archive_filename, FOPEN_AUB);
895 perror (program_name);
899 temp = bfd_openr (archive_filename, NULL);
902 bfd_fatal (archive_filename);
904 if (newfile == false)
906 if (bfd_check_format (temp, bfd_archive) != true)
907 /* xgettext:c-format */
908 fatal (_("%s is not an archive"), archive_filename);
912 fwrite (ARMAG, 1, SARMAG, ofile);
914 /* xgettext:c-format */
915 fprintf (stderr, _("%s: creating %s\n"),
916 program_name, archive_filename);
920 temp->flags |= BFD_TRADITIONAL_FORMAT;
922 /* assume it's an achive, go straight to the end, sans $200 */
925 for (; files_to_append && *files_to_append; ++files_to_append)
927 struct ar_hdr *hdr = bfd_special_undocumented_glue (temp, *files_to_append);
930 bfd_fatal (*files_to_append);
933 BFD_SEND (temp, _bfd_truncate_arname, (temp, *files_to_append, (char *) hdr));
935 ifile = fopen (*files_to_append, FOPEN_RB);
938 bfd_nonfatal (*files_to_append);
941 if (stat (*files_to_append, &sbuf) != 0)
943 bfd_nonfatal (*files_to_append);
946 tocopy = sbuf.st_size;
948 /* XXX should do error-checking! */
949 fwrite (hdr, 1, sizeof (struct ar_hdr), ofile);
954 if (thistime > BUFSIZE)
956 fread (buf, 1, thistime, ifile);
957 fwrite (buf, 1, thistime, ofile);
961 if ((sbuf.st_size % 2) == 1)
962 putc ('\012', ofile);
972 write_archive (iarch)
976 char *old_name, *new_name;
977 bfd *contents_head = iarch->next;
979 old_name = xmalloc (strlen (bfd_get_filename (iarch)) + 1);
980 strcpy (old_name, bfd_get_filename (iarch));
981 new_name = make_tempname (old_name);
983 output_filename = new_name;
985 obfd = bfd_openw (new_name, bfd_get_target (iarch));
988 bfd_fatal (old_name);
992 bfd_set_format (obfd, bfd_archive);
994 /* Request writing the archive symbol table unless we've
995 been explicitly requested not to. */
996 obfd->has_armap = write_armap >= 0;
1000 /* This should really use bfd_set_file_flags, but that rejects
1002 obfd->flags |= BFD_TRADITIONAL_FORMAT;
1005 if (bfd_set_archive_head (obfd, contents_head) != true)
1006 bfd_fatal (old_name);
1008 if (!bfd_close (obfd))
1009 bfd_fatal (old_name);
1012 output_filename = NULL;
1014 /* We don't care if this fails; we might be creating the archive. */
1017 if (smart_rename (new_name, old_name, 0) != 0)
1021 /* Return a pointer to the pointer to the entry which should be rplacd'd
1022 into when altering. DEFAULT_POS should be how to interpret pos_default,
1023 and should be a pos value. */
1026 get_pos_bfd (contents, default_pos, default_posname)
1028 enum pos default_pos;
1029 const char *default_posname;
1031 bfd **after_bfd = contents;
1033 const char *realposname;
1035 if (postype == pos_default)
1037 realpos = default_pos;
1038 realposname = default_posname;
1043 realposname = posname;
1046 if (realpos == pos_end)
1049 after_bfd = &((*after_bfd)->next);
1053 for (; *after_bfd; after_bfd = &(*after_bfd)->next)
1054 if (strcmp ((*after_bfd)->filename, realposname) == 0)
1056 if (realpos == pos_after)
1057 after_bfd = &(*after_bfd)->next;
1065 delete_members (arch, files_to_delete)
1067 char **files_to_delete;
1069 bfd **current_ptr_ptr;
1071 boolean something_changed = false;
1072 for (; *files_to_delete != NULL; ++files_to_delete)
1074 /* In a.out systems, the armap is optional. It's also called
1075 __.SYMDEF. So if the user asked to delete it, we should remember
1076 that fact. This isn't quite right for COFF systems (where
1077 __.SYMDEF might be regular member), but it's very unlikely
1078 to be a problem. FIXME */
1080 if (!strcmp (*files_to_delete, "__.SYMDEF"))
1082 arch->has_armap = false;
1088 current_ptr_ptr = &(arch->next);
1089 while (*current_ptr_ptr)
1091 if (strcmp (*files_to_delete, (*current_ptr_ptr)->filename) == 0)
1094 something_changed = true;
1098 *current_ptr_ptr = ((*current_ptr_ptr)->next);
1103 current_ptr_ptr = &((*current_ptr_ptr)->next);
1107 if (verbose && found == false)
1109 /* xgettext:c-format */
1110 printf (_("No member named `%s'\n"), *files_to_delete);
1116 if (something_changed == true)
1118 write_archive (arch);
1123 /* Reposition existing members within an archive */
1126 move_members (arch, files_to_move)
1128 char **files_to_move;
1130 bfd **after_bfd; /* New entries go after this one */
1131 bfd **current_ptr_ptr; /* cdr pointer into contents */
1133 for (; *files_to_move; ++files_to_move)
1135 current_ptr_ptr = &(arch->next);
1136 while (*current_ptr_ptr)
1138 bfd *current_ptr = *current_ptr_ptr;
1139 if (strcmp (normalize (*files_to_move, arch),
1140 current_ptr->filename) == 0)
1142 /* Move this file to the end of the list - first cut from
1145 *current_ptr_ptr = current_ptr->next;
1147 /* Now glue to end */
1148 after_bfd = get_pos_bfd (&arch->next, pos_end, NULL);
1150 *after_bfd = current_ptr;
1151 current_ptr->next = link;
1154 printf ("m - %s\n", *files_to_move);
1159 current_ptr_ptr = &((*current_ptr_ptr)->next);
1161 /* xgettext:c-format */
1162 fprintf (stderr, _("%s: no entry %s in archive %s!\n"),
1163 program_name, *files_to_move, arch->filename);
1168 write_archive (arch);
1171 /* Ought to default to replacing in place, but this is existing practice! */
1174 replace_members (arch, files_to_move, quick)
1176 char **files_to_move;
1179 boolean changed = false;
1180 bfd **after_bfd; /* New entries go after this one */
1185 while (files_to_move && *files_to_move)
1189 current_ptr = &arch->next;
1190 while (*current_ptr)
1192 current = *current_ptr;
1194 /* For compatibility with existing ar programs, we
1195 permit the same file to be added multiple times. */
1196 if (strcmp (normalize (*files_to_move, arch),
1197 normalize (current->filename, arch)) == 0
1198 && current->arelt_data != NULL)
1202 struct stat fsbuf, asbuf;
1204 if (stat (*files_to_move, &fsbuf) != 0)
1206 if (errno != ENOENT)
1207 bfd_fatal (*files_to_move);
1210 if (bfd_stat_arch_elt (current, &asbuf) != 0)
1211 /* xgettext:c-format */
1212 fatal (_("internal stat error on %s"), current->filename);
1214 if (fsbuf.st_mtime <= asbuf.st_mtime)
1218 after_bfd = get_pos_bfd (&arch->next, pos_after,
1222 *after_bfd = bfd_openr (*files_to_move, NULL);
1223 if (*after_bfd == (bfd *) NULL)
1225 bfd_fatal (*files_to_move);
1227 (*after_bfd)->next = temp;
1229 /* snip out this entry from the chain */
1230 *current_ptr = (*current_ptr)->next;
1234 printf ("r - %s\n", *files_to_move);
1241 current_ptr = &(current->next);
1245 /* Add to the end of the archive. */
1247 after_bfd = get_pos_bfd (&arch->next, pos_end, NULL);
1249 *after_bfd = bfd_openr (*files_to_move, NULL);
1250 if (*after_bfd == (bfd *) NULL)
1252 bfd_fatal (*files_to_move);
1256 printf ("a - %s\n", *files_to_move);
1259 (*after_bfd)->next = temp;
1269 write_archive (arch);
1273 ranlib_only (archname)
1274 const char *archname;
1279 arch = open_inarch (archname, (char *) NULL);
1282 write_archive (arch);
1285 /* Update the timestamp of the symbol map of an archive. */
1288 ranlib_touch (archname)
1289 const char *archname;
1292 /* I don't think updating works on go32. */
1293 ranlib_only (archname);
1299 f = open (archname, O_RDWR, 0);
1302 bfd_set_error (bfd_error_system_call);
1303 bfd_fatal (archname);
1306 arch = bfd_fdopenr (archname, (const char *) NULL, f);
1308 bfd_fatal (archname);
1309 if (! bfd_check_format_matches (arch, bfd_archive, &matching))
1311 bfd_nonfatal (archname);
1312 if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
1314 list_matching_formats (matching);
1320 if (! bfd_has_map (arch))
1321 /* xgettext:c-format */
1322 fatal (_("%s: no archive map to update"), archname);
1324 bfd_update_armap_timestamp (arch);
1326 if (! bfd_close (arch))
1327 bfd_fatal (archname);
1331 /* Things which are interesting to map over all or some of the files: */
1337 print_arelt_descr (stdout, abfd, verbose);