Line 1... |
Line 1... |
/* ar.c - Archive modify and extract.
|
/* ar.c - Archive modify and extract.
|
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
|
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
|
|
This file is part of GNU Binutils.
|
This file is part of GNU Binutils.
|
|
|
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
Line 35... |
Line 35... |
#include "bucomm.h"
|
#include "bucomm.h"
|
#include "arsup.h"
|
#include "arsup.h"
|
#include "filenames.h"
|
#include "filenames.h"
|
#include "binemul.h"
|
#include "binemul.h"
|
#include "plugin.h"
|
#include "plugin.h"
|
#include <sys/stat.h>
|
|
|
|
#ifdef __GO32___
|
#ifdef __GO32___
|
#define EXT_NAME_LEN 3 /* Bufflen of addition to name if it's MS-DOS. */
|
#define EXT_NAME_LEN 3 /* Bufflen of addition to name if it's MS-DOS. */
|
#else
|
#else
|
#define EXT_NAME_LEN 6 /* Ditto for *NIX. */
|
#define EXT_NAME_LEN 6 /* Ditto for *NIX. */
|
Line 95... |
Line 94... |
int write_armap = 0;
|
int write_armap = 0;
|
|
|
/* Operate in deterministic mode: write zero for timestamps, uids,
|
/* Operate in deterministic mode: write zero for timestamps, uids,
|
and gids for archive members and the archive symbol table, and write
|
and gids for archive members and the archive symbol table, and write
|
consistent file modes. */
|
consistent file modes. */
|
int deterministic = 0;
|
int deterministic = -1; /* Determinism indeterminate. */
|
|
|
/* Nonzero means it's the name of an existing member; position new or moved
|
/* Nonzero means it's the name of an existing member; position new or moved
|
files with respect to this one. */
|
files with respect to this one. */
|
char *posname = NULL;
|
char *posname = NULL;
|
|
|
Line 274... |
Line 273... |
fprintf (s, _(" t - display contents of archive\n"));
|
fprintf (s, _(" t - display contents of archive\n"));
|
fprintf (s, _(" x[o] - extract file(s) from the archive\n"));
|
fprintf (s, _(" x[o] - extract file(s) from the archive\n"));
|
fprintf (s, _(" command specific modifiers:\n"));
|
fprintf (s, _(" command specific modifiers:\n"));
|
fprintf (s, _(" [a] - put file(s) after [member-name]\n"));
|
fprintf (s, _(" [a] - put file(s) after [member-name]\n"));
|
fprintf (s, _(" [b] - put file(s) before [member-name] (same as [i])\n"));
|
fprintf (s, _(" [b] - put file(s) before [member-name] (same as [i])\n"));
|
fprintf (s, _(" [D] - use zero for timestamps and uids/gids\n"));
|
if (DEFAULT_AR_DETERMINISTIC)
|
|
{
|
|
fprintf (s, _("\
|
|
[D] - use zero for timestamps and uids/gids (default)\n"));
|
|
fprintf (s, _("\
|
|
[U] - use actual timestamps and uids/gids\n"));
|
|
}
|
|
else
|
|
{
|
|
fprintf (s, _("\
|
|
[D] - use zero for timestamps and uids/gids\n"));
|
|
fprintf (s, _("\
|
|
[U] - use actual timestamps and uids/gids (default)\n"));
|
|
}
|
fprintf (s, _(" [N] - use instance [count] of name\n"));
|
fprintf (s, _(" [N] - use instance [count] of name\n"));
|
fprintf (s, _(" [f] - truncate inserted file names\n"));
|
fprintf (s, _(" [f] - truncate inserted file names\n"));
|
fprintf (s, _(" [P] - use full path names when matching\n"));
|
fprintf (s, _(" [P] - use full path names when matching\n"));
|
fprintf (s, _(" [o] - preserve original dates\n"));
|
fprintf (s, _(" [o] - preserve original dates\n"));
|
fprintf (s, _(" [u] - only replace files that are newer than current archive contents\n"));
|
fprintf (s, _(" [u] - only replace files that are newer than current archive contents\n"));
|
Line 320... |
Line 332... |
@<file> Read options from <file>\n"));
|
@<file> Read options from <file>\n"));
|
#if BFD_SUPPORTS_PLUGINS
|
#if BFD_SUPPORTS_PLUGINS
|
fprintf (s, _("\
|
fprintf (s, _("\
|
--plugin <name> Load the specified plugin\n"));
|
--plugin <name> Load the specified plugin\n"));
|
#endif
|
#endif
|
|
if (DEFAULT_AR_DETERMINISTIC)
|
|
fprintf (s, _("\
|
|
-D Use zero for symbol map timestamp (default)\n\
|
|
-U Use an actual symbol map timestamp\n"));
|
|
else
|
|
fprintf (s, _("\
|
|
-D Use zero for symbol map timestamp\n\
|
|
-U Use actual symbol map timestamp (default)\n"));
|
fprintf (s, _("\
|
fprintf (s, _("\
|
-t Update the archive's symbol map timestamp\n\
|
-t Update the archive's symbol map timestamp\n\
|
-h --help Print this help message\n\
|
-h --help Print this help message\n\
|
-v --version Print version information\n"));
|
-v --version Print version information\n"));
|
|
|
Line 431... |
Line 451... |
|
|
argc = new_argc;
|
argc = new_argc;
|
argv = new_argv;
|
argv = new_argv;
|
}
|
}
|
|
|
while ((c = getopt_long (argc, argv, "hdmpqrtxlcoVsSuvabiMNfPTD",
|
while ((c = getopt_long (argc, argv, "hdmpqrtxlcoVsSuvabiMNfPTDU",
|
long_options, NULL)) != EOF)
|
long_options, NULL)) != EOF)
|
{
|
{
|
switch (c)
|
switch (c)
|
{
|
{
|
case 'd':
|
case 'd':
|
Line 528... |
Line 548... |
make_thin_archive = TRUE;
|
make_thin_archive = TRUE;
|
break;
|
break;
|
case 'D':
|
case 'D':
|
deterministic = TRUE;
|
deterministic = TRUE;
|
break;
|
break;
|
|
case 'U':
|
|
deterministic = FALSE;
|
|
break;
|
case OPTION_PLUGIN:
|
case OPTION_PLUGIN:
|
#if BFD_SUPPORTS_PLUGINS
|
#if BFD_SUPPORTS_PLUGINS
|
plugin_target = "plugin";
|
plugin_target = "plugin";
|
bfd_plugin_set_plugin (optarg);
|
bfd_plugin_set_plugin (optarg);
|
#else
|
#else
|
Line 550... |
Line 573... |
}
|
}
|
|
|
return &argv[optind];
|
return &argv[optind];
|
}
|
}
|
|
|
|
/* If neither -D nor -U was not specified explicitly,
|
|
then use the configured default. */
|
|
static void
|
|
default_deterministic (void)
|
|
{
|
|
if (deterministic < 0)
|
|
deterministic = DEFAULT_AR_DETERMINISTIC;
|
|
}
|
|
|
static void
|
static void
|
ranlib_main (int argc, char **argv)
|
ranlib_main (int argc, char **argv)
|
{
|
{
|
int arg_index, status = 0;
|
int arg_index, status = 0;
|
bfd_boolean touch = FALSE;
|
bfd_boolean touch = FALSE;
|
int c;
|
int c;
|
|
|
while ((c = getopt_long (argc, argv, "hHvVt", long_options, NULL)) != EOF)
|
while ((c = getopt_long (argc, argv, "DhHUvVt", long_options, NULL)) != EOF)
|
{
|
{
|
switch (c)
|
switch (c)
|
{
|
{
|
|
case 'D':
|
|
deterministic = TRUE;
|
|
break;
|
|
case 'U':
|
|
deterministic = FALSE;
|
|
break;
|
case 'h':
|
case 'h':
|
case 'H':
|
case 'H':
|
show_help = 1;
|
show_help = 1;
|
break;
|
break;
|
case 't':
|
case 't':
|
Line 572... |
Line 610... |
break;
|
break;
|
case 'v':
|
case 'v':
|
case 'V':
|
case 'V':
|
show_version = 1;
|
show_version = 1;
|
break;
|
break;
|
|
|
|
/* PR binutils/13493: Support plugins. */
|
|
case OPTION_PLUGIN:
|
|
#if BFD_SUPPORTS_PLUGINS
|
|
plugin_target = "plugin";
|
|
bfd_plugin_set_plugin (optarg);
|
|
#else
|
|
fprintf (stderr, _("sorry - this program has been built without plugin support\n"));
|
|
xexit (1);
|
|
#endif
|
|
break;
|
}
|
}
|
}
|
}
|
|
|
if (argc < 2)
|
if (argc < 2)
|
ranlib_usage (0);
|
ranlib_usage (0);
|
|
|
if (show_help)
|
if (show_help)
|
usage (1);
|
ranlib_usage (1);
|
|
|
if (show_version)
|
if (show_version)
|
print_version ("ranlib");
|
print_version ("ranlib");
|
|
|
|
default_deterministic ();
|
|
|
arg_index = optind;
|
arg_index = optind;
|
|
|
while (arg_index < argc)
|
while (arg_index < argc)
|
{
|
{
|
if (! touch)
|
if (! touch)
|
Line 693... |
Line 744... |
fatal (_("no operation specified"));
|
fatal (_("no operation specified"));
|
|
|
if (newer_only && operation != replace)
|
if (newer_only && operation != replace)
|
fatal (_("`u' is only meaningful with the `r' option."));
|
fatal (_("`u' is only meaningful with the `r' option."));
|
|
|
if (newer_only && deterministic)
|
if (newer_only && deterministic > 0)
|
fatal (_("`u' is not meaningful with the `D' option."));
|
fatal (_("`u' is not meaningful with the `D' option."));
|
|
|
|
if (newer_only && deterministic < 0 && DEFAULT_AR_DETERMINISTIC)
|
|
non_fatal (_("\
|
|
`u' modifier ignored since `D' is the default (see `U')"));
|
|
|
|
default_deterministic ();
|
|
|
if (postype != pos_default)
|
if (postype != pos_default)
|
posname = argv[arg_index++];
|
posname = argv[arg_index++];
|
|
|
if (counted_name_mode)
|
if (counted_name_mode)
|
{
|
{
|
Line 1363... |
Line 1420... |
|
|
if (! bfd_has_map (arch))
|
if (! bfd_has_map (arch))
|
/* xgettext:c-format */
|
/* xgettext:c-format */
|
fatal (_("%s: no archive map to update"), archname);
|
fatal (_("%s: no archive map to update"), archname);
|
|
|
|
if (deterministic)
|
|
arch->flags |= BFD_DETERMINISTIC_OUTPUT;
|
|
|
bfd_update_armap_timestamp (arch);
|
bfd_update_armap_timestamp (arch);
|
|
|
if (! bfd_close (arch))
|
if (! bfd_close (arch))
|
bfd_fatal (archname);
|
bfd_fatal (archname);
|
#endif
|
#endif
|