Change the default behaviour of the PE targeted linker so that timestamps are
authorLinda Zhang <lindasc@qq.com>
Thu, 26 Jun 2014 11:18:39 +0000 (12:18 +0100)
committerNick Clifton <nickc@redhat.com>
Thu, 26 Jun 2014 11:18:39 +0000 (12:18 +0100)
inserted.  This is for compatibility with other, non-GNU tools.  Deterministic
binaries can still be created by using the new --no-insert-timestamp command line
option.

* emultempl/pe.em: Initialise insert_timestamp to true.
Add a --no-insert-timestamp command line option.
* emultempl/pep.em: Likewise.
* ld.texinfo: Document that --insert-timestamp is enabled by
default and that it now has an inverse command line option.
* NEWS: Mention the new behaviour.

ld/ChangeLog
ld/NEWS
ld/emultempl/pe.em
ld/emultempl/pep.em
ld/ld.texinfo

index 5a1fe27708552bbee4f53dd1e2190aa1a22f1908..f42d00bf1a019ebece7dab8de4e192979c236b6d 100644 (file)
@@ -1,3 +1,12 @@
+2014-06-26  Linda Zhang  <lindasc@qq.com>
+
+       * emultempl/pe.em: Initialise insert_timestamp to true.
+       Add a --no-insert-timestamp command line option.
+       * emultempl/pep.em: Likewise.
+       * ld.texinfo: Document that --insert-timestamp is enabled by
+       default and that it now has an inverse command line option.
+       * NEWS: Mention the new behaviour.
+
 2014-06-25  Nick Clifton  <nickc@redhat.com>
 
        * Makefile.am (ALL_EMULATION_SOURCES): Move ei386pep.c from
diff --git a/ld/NEWS b/ld/NEWS
index 344f98d8a91f8de96ea77ca5b2e1dbabe81b8d58..a8b4ab46a7b91bde4a6609390e0a7fe45c0c4aa9 100644 (file)
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,5 +1,9 @@
 -*- text -*-
 
+* PE binaries now once again contain real timestamps by default.  To disable
+  the inclusion of a timestamp in a PE binary, use the --no-insert-timestamp
+  command line option.
+
 * Replace support for openrisc and or32 with support for or1k.
 
 * Add support for the --build-id command line option to COFF based targets.
index 0466eb3f631e16ae580344f32406f39be5fa58a3..7a5b77bf9b21d19b0da86458ae441258a48d1191 100644 (file)
@@ -132,7 +132,7 @@ static int support_old_code = 0;
 static char * thumb_entry_symbol = NULL;
 static lang_assignment_statement_type *image_base_statement = 0;
 static unsigned short pe_dll_characteristics = 0;
-static bfd_boolean insert_timestamp = FALSE;
+static bfd_boolean insert_timestamp = TRUE;
 static const char *emit_build_id;
 
 #ifdef DLL_SUPPORT
@@ -272,7 +272,8 @@ fragment <<EOF
 #define OPTION_TERMINAL_SERVER_AWARE   (OPTION_WDM_DRIVER + 1)
 /* Determinism.  */
 #define OPTION_INSERT_TIMESTAMP                (OPTION_TERMINAL_SERVER_AWARE + 1)
-#define OPTION_BUILD_ID                        (OPTION_INSERT_TIMESTAMP + 1)
+#define OPTION_NO_INSERT_TIMESTAMP     (OPTION_INSERT_TIMESTAMP + 1)
+#define OPTION_BUILD_ID                        (OPTION_NO_INSERT_TIMESTAMP + 1)
 
 static void
 gld${EMULATION_NAME}_add_options
@@ -307,6 +308,7 @@ gld${EMULATION_NAME}_add_options
     {"no-leading-underscore", no_argument, NULL, OPTION_NO_LEADING_UNDERSCORE},
     {"leading-underscore", no_argument, NULL, OPTION_LEADING_UNDERSCORE},
     {"insert-timestamp", no_argument, NULL, OPTION_INSERT_TIMESTAMP},
+    {"no-insert-timestamp", no_argument, NULL, OPTION_NO_INSERT_TIMESTAMP},
 #ifdef DLL_SUPPORT
     /* getopt allows abbreviations, so we do this to stop it
        from treating -o as an abbreviation for this option.  */
@@ -445,7 +447,7 @@ gld_${EMULATION_NAME}_list_options (FILE *file)
   fprintf (file, _("  --support-old-code                 Support interworking with old code\n"));
   fprintf (file, _("  --[no-]leading-underscore          Set explicit symbol underscore prefix mode\n"));
   fprintf (file, _("  --thumb-entry=<symbol>             Set the entry point to be Thumb <symbol>\n"));
-  fprintf (file, _("  --insert-timestamp                 Use a real timestamp rather than zero.\n"));
+  fprintf (file, _("  --[no-]insert-timestamp            Use a real timestamp rather than zero (default).\n"));
   fprintf (file, _("                                     This makes binaries non-deterministic\n"));
 #ifdef DLL_SUPPORT
   fprintf (file, _("  --add-stdcall-alias                Export symbols with and without @nn\n"));
@@ -769,6 +771,9 @@ gld${EMULATION_NAME}_handle_option (int optc)
     case OPTION_INSERT_TIMESTAMP:
       insert_timestamp = TRUE;
       break;
+    case OPTION_NO_INSERT_TIMESTAMP:
+      insert_timestamp = FALSE;
+      break;
 #ifdef DLL_SUPPORT
     case OPTION_OUT_DEF:
       pe_out_def_filename = xstrdup (optarg);
index 6e3ecd80011cbfb1fef92ffa731c34dfbc668166..916a786da0f40747dfac8fa4759d225f4b4c19ce 100644 (file)
@@ -147,7 +147,7 @@ static flagword real_flags = IMAGE_FILE_LARGE_ADDRESS_AWARE;
 static int support_old_code = 0;
 static lang_assignment_statement_type *image_base_statement = 0;
 static unsigned short pe_dll_characteristics = 0;
-static bfd_boolean insert_timestamp = FALSE;
+static bfd_boolean insert_timestamp = TRUE;
 static const char *emit_build_id;
 
 #ifdef DLL_SUPPORT
@@ -245,6 +245,7 @@ enum options
   OPTION_NO_BIND,
   OPTION_WDM_DRIVER,
   OPTION_INSERT_TIMESTAMP,
+  OPTION_NO_INSERT_TIMESTAMP,
   OPTION_TERMINAL_SERVER_AWARE,
   OPTION_BUILD_ID
 };
@@ -322,6 +323,7 @@ gld${EMULATION_NAME}_add_options
     {"wdmdriver", no_argument, NULL, OPTION_WDM_DRIVER},
     {"tsaware", no_argument, NULL, OPTION_TERMINAL_SERVER_AWARE},
     {"insert-timestamp", no_argument, NULL, OPTION_INSERT_TIMESTAMP},
+    {"no-insert-timestamp", no_argument, NULL, OPTION_NO_INSERT_TIMESTAMP},
     {"build-id", optional_argument, NULL, OPTION_BUILD_ID},
     {NULL, no_argument, NULL, 0}
   };
@@ -409,7 +411,7 @@ gld_${EMULATION_NAME}_list_options (FILE *file)
   fprintf (file, _("  --subsystem <name>[:<version>]     Set required OS subsystem [& version]\n"));
   fprintf (file, _("  --support-old-code                 Support interworking with old code\n"));
   fprintf (file, _("  --[no-]leading-underscore          Set explicit symbol underscore prefix mode\n"));
-  fprintf (file, _("  --insert-timestamp                 Use a real timestamp rather than zero.\n"));
+  fprintf (file, _("  --[no-]insert-timestamp            Use a real timestamp rather than zero. (default)\n"));
   fprintf (file, _("                                     This makes binaries non-deterministic\n"));
 #ifdef DLL_SUPPORT
   fprintf (file, _("  --add-stdcall-alias                Export symbols with and without @nn\n"));
@@ -721,6 +723,9 @@ gld${EMULATION_NAME}_handle_option (int optc)
     case OPTION_INSERT_TIMESTAMP:
       insert_timestamp = TRUE;
       break;
+    case OPTION_NO_INSERT_TIMESTAMP:
+      insert_timestamp = FALSE;
+      break;
 #ifdef DLL_SUPPORT
     case OPTION_OUT_DEF:
       pep_out_def_filename = xstrdup (optarg);
index e3d046941a8edadeeaa6f057b16cb174ad61dbd3..5762dc6e3602eaae4036042da278c5608de18ee5 100644 (file)
@@ -2665,9 +2665,15 @@ The image is Terminal Server aware.
 
 @kindex --insert-timestamp
 @item --insert-timestamp
-Insert a real timestamp into the image, rather than the default value
-of zero.  This will result in a slightly different results with each
-invocation, which could be helpful for distributing unique images.
+@itemx --no-insert-timestamp
+Insert a real timestamp into the image.  This is the default behaviour
+as it matches legacy code and it means that the image will work with
+other, proprietary tools.  The problem with this default is that it
+will result in slightly different images being produced each tiem the
+same sources are linked.  The option @option{--no-insert-timestamp}
+can be used to insert a zero value for the timestamp, this ensuring
+that binaries produced from indentical sources will compare
+identically.
 @end table
 
 @c man end