[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.
This commit is contained in:
Chris Demetriou
2009-03-11 04:36:40 +00:00
parent a07dbd482b
commit 36e4dce69d
9 changed files with 144 additions and 5 deletions

View File

@@ -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;