X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=binutils%2Far.c;h=5bffd50a66bb6d3306e1ae1ea2bc737d96431494;hb=3f5e193bd6e036c43af9326d777aed6cfc14fbcb;hp=71f4d734612e203f00ad4c40d76d034529c478fd;hpb=a8da6403829d6f87867da6a737dfdaa736a37dfa;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/ar.c b/binutils/ar.c index 71f4d73461..5bffd50a66 100644 --- a/binutils/ar.c +++ b/binutils/ar.c @@ -1,6 +1,6 @@ /* ar.c - Archive modify and extract. Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -37,6 +37,7 @@ #include "arsup.h" #include "filenames.h" #include "binemul.h" +#include "plugin.h" #include #ifdef __GO32___ @@ -45,12 +46,6 @@ #define EXT_NAME_LEN 6 /* Ditto for *NIX. */ #endif -/* We need to open files in binary modes on system where that makes a - difference. */ -#ifndef O_BINARY -#define O_BINARY 0 -#endif - /* Kludge declaration from BFD! This is ugly! FIXME! XXX */ struct ar_hdr * @@ -105,6 +100,11 @@ int newer_only = 0; if any of the members are object files. */ int write_armap = 0; +/* Operate in deterministic mode: write zero for timestamps, uids, + and gids for archive members and the archive symbol table, and write + consistent file modes. */ +int deterministic = 0; + /* Nonzero means it's the name of an existing member; position new or moved files with respect to this one. */ char *posname = NULL; @@ -231,8 +231,14 @@ usage (int help) if (! is_ranlib) { /* xgettext:c-format */ - fprintf (s, _("Usage: %s [emulation options] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...\n"), - program_name); + const char * command_line = +#if BFD_SUPPORTS_PLUGINS + _("Usage: %s [emulation options] [--plugin ] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...\n"); +#else + _("Usage: %s [emulation options] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...\n"); +#endif + fprintf (s, command_line, program_name); + /* xgettext:c-format */ fprintf (s, _(" %s -M [ - read options from \n")); - +#if BFD_SUPPORTS_PLUGINS + fprintf (s, _(" optional:\n")); + fprintf (s, _(" --plugin

- load the specified plugin\n")); +#endif ar_emul_usage (s); } else @@ -268,7 +278,12 @@ usage (int help) fprintf (s, _("Usage: %s [options] archive\n"), program_name); fprintf (s, _(" Generate an index to speed access to archives\n")); fprintf (s, _(" The options are:\n\ - @ Read options from \n\ + @ Read options from \n")); +#if BFD_SUPPORTS_PLUGINS + fprintf (s, _("\ + --plugin Load the specified plugin\n")); +#endif + fprintf (s, _("\ -t Update the archive's symbol map timestamp\n\ -h --help Print this help message\n\ -v --version Print version information\n")); @@ -317,7 +332,7 @@ normalize (const char *file, bfd *abfd) char *s; /* Space leak. */ - s = xmalloc (abfd->xvec->ar_max_namelen + 1); + s = (char *) xmalloc (abfd->xvec->ar_max_namelen + 1); memcpy (s, filename, abfd->xvec->ar_max_namelen); s[abfd->xvec->ar_max_namelen] = '\0'; filename = s; @@ -357,7 +372,7 @@ main (int argc, char **argv) char c; enum { - none = 0, delete, replace, print_table, + none = 0, del, replace, print_table, print_files, extract, move, quick_append } operation = none; int arg_index; @@ -379,6 +394,9 @@ main (int argc, char **argv) program_name = argv[0]; xmalloc_set_program_name (program_name); +#if BFD_SUPPORTS_PLUGINS + bfd_plugin_set_program_name (program_name); +#endif expandargv (&argc, &argv); @@ -480,6 +498,22 @@ main (int argc, char **argv) arg_index = 1; arg_ptr = argv[arg_index]; + if (strcmp (arg_ptr, "--plugin") == 0) + { +#if BFD_SUPPORTS_PLUGINS + if (argc < 4) + usage (1); + + bfd_plugin_set_plugin (argv[2]); + + arg_index += 2; + arg_ptr = argv[arg_index]; +#else + fprintf (stderr, _("sorry - this program has been built without plugin support\n")); + xexit (1); +#endif + } + if (*arg_ptr == '-') { /* When the first option starts with '-' we support POSIX-compatible @@ -506,7 +540,7 @@ main (int argc, char **argv) switch (c) { case 'd': - operation = delete; + operation = del; operation_alters_arch = TRUE; break; case 'm': @@ -578,6 +612,9 @@ main (int argc, char **argv) case 'T': make_thin_archive = TRUE; break; + case 'D': + deterministic = TRUE; + break; default: /* xgettext:c-format */ non_fatal (_("illegal option -- %c"), c); @@ -628,12 +665,15 @@ main (int argc, char **argv) if (newer_only && operation != replace) fatal (_("`u' is only meaningful with the `r' option.")); + if (newer_only && deterministic) + fatal (_("`u' is not meaningful with the `D' option.")); + if (postype != pos_default) posname = argv[arg_index++]; if (counted_name_mode) { - if (operation != extract && operation != delete) + if (operation != extract && operation != del) fatal (_("`N' is only meaningful with the `x' and `d' options.")); counted_name_counter = atoi (argv[arg_index++]); if (counted_name_counter <= 0) @@ -665,7 +705,7 @@ main (int argc, char **argv) map_over_members (arch, extract_file, files, file_count); break; - case delete: + case del: if (files != NULL) delete_members (arch, files); else @@ -803,7 +843,7 @@ static void print_contents (bfd *abfd) { size_t ncopied = 0; - char *cbuf = xmalloc (BUFSIZE); + char *cbuf = (char *) xmalloc (BUFSIZE); struct stat buf; size_t size; if (bfd_stat_arch_elt (abfd, &buf) != 0) @@ -855,7 +895,7 @@ void extract_file (bfd *abfd) { FILE *ostream; - char *cbuf = xmalloc (BUFSIZE); + char *cbuf = (char *) xmalloc (BUFSIZE); size_t nread, tocopy; size_t ncopied = 0; size_t size; @@ -949,7 +989,7 @@ write_archive (bfd *iarch) char *old_name, *new_name; bfd *contents_head = iarch->archive_next; - old_name = xmalloc (strlen (bfd_get_filename (iarch)) + 1); + old_name = (char *) xmalloc (strlen (bfd_get_filename (iarch)) + 1); strcpy (old_name, bfd_get_filename (iarch)); new_name = make_tempname (old_name); @@ -978,6 +1018,9 @@ write_archive (bfd *iarch) obfd->flags |= BFD_TRADITIONAL_FORMAT; } + if (deterministic) + obfd->flags |= BFD_DETERMINISTIC_OUTPUT; + if (make_thin_archive || bfd_is_thin_archive (iarch)) bfd_is_thin_archive (obfd) = 1;