summaryrefslogtreecommitdiff
path: root/binutils/ar.c
diff options
context:
space:
mode:
authorChris Demetriou <cgd@broadcom.com>2009-03-11 04:36:40 +0000
committerChris Demetriou <cgd@broadcom.com>2009-03-11 04:36:40 +0000
commita0346b11fd7259e092fd519224f4be7d45c46cd4 (patch)
treef5f93f002f0595dcd31aae891618b8a3ad4e535a /binutils/ar.c
parent473440fb31d2db0d54eb815a05db8863a444e992 (diff)
downloadbinutils-redhat-a0346b11fd7259e092fd519224f4be7d45c46cd4.tar.gz
[bfd/ChangeLog]
2009-03-11 Chris Demetriou <cgd@google.com> * bfd.c (BFD_DETERMINISTIC_OUTPUT): New flag. * bfd-in2.h: Regenerate. * archive.c (bfd_ar_hdr_from_filesystem): If BFD_DETERMINISTIC_OUTPUT flag is set, use 0 for uid, gid, and timestamp, and use 0644 for file mode. (bsd_write_armap): Likewise. (_bfd_archive_bsd_update_armap_timestamp): If BFD_DETERMINISTIC_OUTPUT flag is set, do nothing. (coff_write_armap): If BFD_DETERMINISTIC_OUTPUT flag is set, use 0 for timestamp. [binutils/ChangeLog] 2009-03-11 Chris Demetriou <cgd@google.com> * ar.c (deterministic): New global variable. (main): Recognize new 'D' option, which enables 'deterministic mode'. (usage): Document new 'D' option. (write_archive): Set BFD_DETERMINISTIC_OUTPUT in output archive's flags if deterministic mode was requested. * doc/binutils.texi (ar): Document deterministic mode ('D' option). [binutils/testsuite/ChangeLog] 2009-03-11 Chris Demetriou <cgd@google.com> * binutils-all/ar.exp (deterministic_archive): New test.
Diffstat (limited to 'binutils/ar.c')
-rw-r--r--binutils/ar.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/binutils/ar.c b/binutils/ar.c
index f4932219b7..73ab1d46f0 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -99,6 +99,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;
@@ -240,6 +245,7 @@ usage (int help)
fprintf (s, _(" command specific modifiers:\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, _(" [D] - use zero for timestamps and uids/gids\n"));
fprintf (s, _(" [N] - use instance [count] of name\n"));
fprintf (s, _(" [f] - truncate inserted file names\n"));
fprintf (s, _(" [P] - use full path names when matching\n"));
@@ -572,6 +578,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);
@@ -622,6 +631,9 @@ 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++];
@@ -972,6 +984,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;