This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] support -U and respect configure --enable-deterministic-archives in objcopy/strip


When I added the --enable-deterministic-archives configure option and the
-U option to ar/ranlib, I forgot that strip/objcopy also independently
implement archive handling and need the same treatment.

Ok for trunk and 2.23?


Thanks,
Roland


binutils/
2013-01-04  Roland McGrath  <mcgrathr@google.com>

	* objcopy.c (deterministic): Make int rather than bfd_boolean,
	initialize to -1.
	(strip_options, copy_options): Add -U/--disable-deterministic-archives.
	(default_deterministic): New function.
	(strip_main, copy_main): Handle -U.  Call default_deterministic.
	(copy_usage, strip_usage): Describe -U.  Cite whether -D or -U is
	the default based on DEFAULT_AR_DETERMINISTIC.
	* doc/binutils.texi (objcopy, strip): Describe -U and effect of
	configure options on -D.

	* ar.c (default_deterministic): Comment fix.

--- 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, 2009, 2010, 2011, 2012
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
    Free Software Foundation, Inc.

    This file is part of GNU Binutils.
@@ -575,7 +575,7 @@ decode_options (int argc, char **argv)
   return &argv[optind];
 }

-/* If neither -D nor -U was not specified explicitly,
+/* If neither -D nor -U was specified explicitly,
    then use the configured default.  */
 static void
 default_deterministic (void)
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -12,7 +12,7 @@
 @c man begin COPYRIGHT
 Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-2010, 2011, 2012
+2010, 2011, 2012, 2013
 Free Software Foundation, Inc.

 Permission is granted to copy, distribute and/or modify this document
@@ -1069,6 +1069,7 @@ objcopy [@option{-F}
@var{bfdname}|@option{--target=}@var{bfdname}]
         [@option{-R}
@var{sectionname}|@option{--remove-section=}@var{sectionname}]
         [@option{-p}|@option{--preserve-dates}]
         [@option{-D}|@option{--enable-deterministic-archives}]
+        [@option{-U}|@option{--disable-deterministic-archives}]
         [@option{--debugging}]
         [@option{--gap-fill=}@var{val}]
         [@option{--pad-to=}@var{address}]
@@ -1337,10 +1338,28 @@ as those of the input file.

 @item -D
 @itemx --enable-deterministic-archives
+@cindex deterministic archives
+@kindex --enable-deterministic-archives
 Operate in @emph{deterministic} mode.  When copying archive members
 and writing the archive index, use zero for UIDs, GIDs, timestamps,
 and use consistent file modes for all files.

+If @file{binutils} was configured with
+@option{--enable-deterministic-archives}, then this mode is on by default.
+It can be disabled with the @samp{-U} option, below.
+
+@item -U
+@itemx --disable-deterministic-archives
+@cindex deterministic archives
+@kindex --enable-deterministic-archives
+Do @emph{not} operate in @emph{deterministic} mode.  This is the
+inverse of the @option{-D} option, above: when copying archive members
+and writing the archive index, use their actual UID, GID, timestamp,
+and file mode values.
+
+This is the default unless @file{binutils} was configured with
+@option{--enable-deterministic-archives}.
+
 @item --debugging
 Convert debugging information, if possible.  This is not the default
 because only certain debugging formats are supported, and the
@@ -2718,6 +2737,7 @@ strip [@option{-F} @var{bfdname}
|@option{--target=}@var{bfdname}]
       [@option{-R} @var{sectionname}
|@option{--remove-section=}@var{sectionname}]
       [@option{-o} @var{file}] [@option{-p}|@option{--preserve-dates}]
       [@option{-D}|@option{--enable-deterministic-archives}]
+      [@option{-U}|@option{--disable-deterministic-archives}]
       [@option{--keep-file-symbols}]
       [@option{--only-keep-debug}]
       [@option{-v} |@option{--verbose}] [@option{-V}|@option{--version}]
@@ -2810,10 +2830,28 @@ Preserve the access and modification dates of the file.

 @item -D
 @itemx --enable-deterministic-archives
+@cindex deterministic archives
+@kindex --enable-deterministic-archives
 Operate in @emph{deterministic} mode.  When copying archive members
 and writing the archive index, use zero for UIDs, GIDs, timestamps,
 and use consistent file modes for all files.

+If @file{binutils} was configured with
+@option{--enable-deterministic-archives}, then this mode is on by default.
+It can be disabled with the @samp{-U} option, below.
+
+@item -U
+@itemx --disable-deterministic-archives
+@cindex deterministic archives
+@kindex --enable-deterministic-archives
+Do @emph{not} operate in @emph{deterministic} mode.  This is the
+inverse of the @option{-D} option, above: when copying archive members
+and writing the archive index, use their actual UID, GID, timestamp,
+and file mode values.
+
+This is the default unless @file{binutils} was configured with
+@option{--enable-deterministic-archives}.
+
 @item -w
 @itemx --wildcard
 Permit regular expressions in @var{symbolname}s used in other command
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1,6 +1,6 @@
 /* objcopy.c -- copy object file from input to output, optionally massaging it.
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
    Free Software Foundation, Inc.

    This file is part of GNU Binutils.
@@ -86,7 +86,7 @@ static int copy_width = 1;

 static bfd_boolean verbose;		/* Print file and target names.  */
 static bfd_boolean preserve_dates;	/* Preserve input file timestamp.  */
-static bfd_boolean deterministic;	/* Enable deterministic archives.  */
+static int deterministic = -1;		/* Enable deterministic archives.  */
 static int status = 0;		/* Exit status.  */

 enum strip_action
@@ -325,6 +325,7 @@ enum command_line_switch

 static struct option strip_options[] =
 {
+  {"disable-deterministic-archives", no_argument, 0, 'U'},
   {"discard-all", no_argument, 0, 'x'},
   {"discard-locals", no_argument, 0, 'X'},
   {"enable-deterministic-archives", no_argument, 0, 'D'},
@@ -376,6 +377,7 @@ static struct option copy_options[] =
   {"compress-debug-sections", no_argument, 0, OPTION_COMPRESS_DEBUG_SECTIONS},
   {"debugging", no_argument, 0, OPTION_DEBUGGING},
   {"decompress-debug-sections", no_argument, 0,
OPTION_DECOMPRESS_DEBUG_SECTIONS},
+  {"disable-deterministic-archives", no_argument, 0, 'U'},
   {"discard-all", no_argument, 0, 'x'},
   {"discard-locals", no_argument, 0, 'X'},
   {"enable-deterministic-archives", no_argument, 0, 'D'},
@@ -489,9 +491,20 @@ copy_usage (FILE *stream, int exit_status)
   -B --binary-architecture <arch>  Set output arch, when input is arch-less\n\
   -F --target <bfdname>            Set both input and output format
to <bfdname>\n\
      --debugging                   Convert debugging information, if
possible\n\
-  -p --preserve-dates              Copy modified/access timestamps to
the output\n\
+  -p --preserve-dates              Copy modified/access timestamps to
the output\n"));
+  if (DEFAULT_AR_DETERMINISTIC)
+    fprintf (stream, _("\
+  -D --enable-deterministic-archives\n\
+                                   Produce deterministic output when
stripping archives (default)\n\
+  -U --disable-deterministic-archives\n\
+                                   Disable -D behavior\n"));
+  else
+    fprintf (stream, _("\
   -D --enable-deterministic-archives\n\
                                    Produce deterministic output when
stripping archives\n\
+  -U --disable-deterministic-archives\n\
+                                   Disable -D behavior (default)\n"));
+  fprintf (stream, _("\
   -j --only-section <name>         Only copy section <name> into the output\n\
      --add-gnu-debuglink=<file>    Add section .gnu_debuglink linking
to <file>\n\
   -R --remove-section <name>       Remove section <name> from the output\n\
@@ -602,8 +615,20 @@ strip_usage (FILE *stream, int exit_status)
   -O --output-target=<bfdname>     Create an output file in format <bfdname>\n\
   -F --target=<bfdname>            Set both input and output format
to <bfdname>\n\
   -p --preserve-dates              Copy modified/access timestamps to
the output\n\
+"));
+  if (DEFAULT_AR_DETERMINISTIC)
+    fprintf (stream, _("\
+  -D --enable-deterministic-archives\n\
+                                   Produce deterministic output when
stripping archives (default)\n\
+  -U --disable-deterministic-archives\n\
+                                   Disable -D behavior\n"));
+  else
+    fprintf (stream, _("\
   -D --enable-deterministic-archives\n\
                                    Produce deterministic output when
stripping archives\n\
+  -U --disable-deterministic-archives\n\
+                                   Disable -D behavior (default)\n"));
+  fprintf (stream, _("\
   -R --remove-section=<name>       Remove section <name> from the output\n\
   -s --strip-all                   Remove all symbol and relocation
information\n\
   -g -S -d --strip-debug           Remove all debugging symbols & sections\n\
@@ -3025,6 +3050,15 @@ write_debugging_info (bfd *obfd, void *dhandle,
   return FALSE;
 }

+/* If neither -D nor -U was specified explicitly,
+   then use the configured default.  */
+static void
+default_deterministic (void)
+{
+  if (deterministic < 0)
+    deterministic = DEFAULT_AR_DETERMINISTIC;
+}
+
 static int
 strip_main (int argc, char *argv[])
 {
@@ -3085,6 +3119,9 @@ strip_main (int argc, char *argv[])
 	case 'D':
 	  deterministic = TRUE;
 	  break;
+	case 'U':
+	  deterministic = FALSE;
+	  break;
 	case 'x':
 	  discard_locals = LOCALS_ALL;
 	  break;
@@ -3129,6 +3166,8 @@ strip_main (int argc, char *argv[])
   if (show_version)
     print_version ("strip");

+  default_deterministic ();
+
   /* Default is to strip all symbols.  */
   if (strip_symbols == STRIP_UNDEF
       && discard_locals == LOCALS_UNDEF
@@ -3453,6 +3492,10 @@ copy_main (int argc, char *argv[])
 	  deterministic = TRUE;
 	  break;

+	case 'U':
+	  deterministic = FALSE;
+	  break;
+
 	case 'w':
 	  wildcard = TRUE;
 	  break;
@@ -3975,6 +4018,8 @@ copy_main (int argc, char *argv[])
   if (optind + 1 < argc)
     output_filename = argv[optind + 1];

+  default_deterministic ();
+
   /* Default is to strip no symbols.  */
   if (strip_symbols == STRIP_UNDEF && discard_locals == LOCALS_UNDEF)
     strip_symbols = STRIP_NONE;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]