]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add an option to dlltool to allow the creation of deterministic libraries.
authorNick Clifton <nickc@redhat.com>
Tue, 23 Aug 2022 08:54:52 +0000 (09:54 +0100)
committerNick Clifton <nickc@redhat.com>
Tue, 23 Aug 2022 08:54:52 +0000 (09:54 +0100)
PR 29489
* dlltool.c (deterministic): New variable.
(gen_lib_file): If deterministic is true set the
BFD_DETERMINISTIC_OUTPUT flag.
(usage): Mention --deterministic-libraries and
--non-deterministic-libraries.
(long_options): Add new options.
(main): Parse new options.
* doc/binutils.texi: Document the new options.
* NEWS: Mention the new feature.

binutils/ChangeLog
binutils/NEWS
binutils/dlltool.c
binutils/doc/binutils.texi

index e01db7db521e41c701c92def014d35584ca61803..04ef77c55307a57a004a239c53adda21d96c4b98 100644 (file)
@@ -1,3 +1,16 @@
+2022-08-23  Nick Clifton  <nickc@redhat.com>
+
+       PR 29489
+       * dlltool.c (deterministic): New variable.
+       (gen_lib_file): If deterministic is true set the
+       BFD_DETERMINISTIC_OUTPUT flag.
+       (usage): Mention --deterministic-libraries and
+       --non-deterministic-libraries.
+       (long_options): Add new options.
+       (main): Parse new options.
+       * doc/binutils.texi: Document the new options.
+       * NEWS: Mention the new feature.
+
 2022-08-22  Nick Clifton  <nickc@redhat.com>
 
        * readelf.c (check_magic_number): New function.  Checks the magic
index 4fdf1c3b4e85684c6fbec1f5f15ae4a39cfde487..8c2c416c17e4fb8a453a501c3bc27deec94e6c7d 100644 (file)
@@ -1,5 +1,10 @@
 -*- text -*-
 
+* The dlltool program now accepts --deterministic-libraries and
+  --non-deterministic-libraries as command line options to control whether or
+  not it generates deterministic output libraries.  If neither of these options
+  are used the default is whatever was set when the binutils were configured.
+  
 Changes in 2.39:
 
 * Add --no-weak/-W option to nm to make it ignore weak symbols.
index e2af20847009945b4c61a6fef08268fbb4429715..b4ac842212a90ff7fb7e046ec56bd2d8857c0318 100644 (file)
@@ -356,6 +356,7 @@ static char *imp_name;
 static char *delayimp_name;
 static char *identify_imp_name;
 static bool identify_strict;
+static bool deterministic = DEFAULT_AR_DETERMINISTIC;
 
 /* Types used to implement a linked list of dllnames associated
    with the specified import lib. Used by the identify_* code.
@@ -2942,6 +2943,9 @@ gen_lib_file (int delay)
   outarch->has_armap = 1;
   outarch->is_thin_archive = 0;
 
+  if (deterministic)
+    outarch->flags |= BFD_DETERMINISTIC_OUTPUT;
+
   /* Work out a reasonable size of things to put onto one line.  */
   if (delay)
     {
@@ -3674,6 +3678,16 @@ usage (FILE *file, int status)
   fprintf (file, _("   -e --output-exp <outname> Generate an export file.\n"));
   fprintf (file, _("   -l --output-lib <outname> Generate an interface library.\n"));
   fprintf (file, _("   -y --output-delaylib <outname> Create a delay-import library.\n"));
+  fprintf (file, _("      --deterministic-libraries\n"));
+  if (DEFAULT_AR_DETERMINISTIC)
+    fprintf (file, _("                             Use zero for timestamps and uids/gids in output libraries (default)\n"));
+  else
+    fprintf (file, _("                             Use zero for timestamps and uids/gids in output libraries\n"));
+  fprintf (file, _("      --non-deterministic-libraries\n"));
+  if (DEFAULT_AR_DETERMINISTIC)
+    fprintf (file, _("                             Use actual timestamps and uids/gids in output libraries\n"));
+  else
+    fprintf (file, _("                             Use actual timestamps and uids/gids in output libraries (default)\n"));
   fprintf (file, _("   -a --add-indirect         Add dll indirects to export file.\n"));
   fprintf (file, _("   -D --dllname <name>       Name of input dll to put into interface lib.\n"));
   fprintf (file, _("   -d --input-def <deffile>  Name of .def file to be read in.\n"));
@@ -3714,55 +3728,61 @@ usage (FILE *file, int status)
   exit (status);
 }
 
-#define OPTION_EXPORT_ALL_SYMS         150
-#define OPTION_NO_EXPORT_ALL_SYMS      (OPTION_EXPORT_ALL_SYMS + 1)
-#define OPTION_EXCLUDE_SYMS            (OPTION_NO_EXPORT_ALL_SYMS + 1)
-#define OPTION_NO_DEFAULT_EXCLUDES     (OPTION_EXCLUDE_SYMS + 1)
-#define OPTION_ADD_STDCALL_UNDERSCORE  (OPTION_NO_DEFAULT_EXCLUDES + 1)
-#define OPTION_USE_NUL_PREFIXED_IMPORT_TABLES \
-  (OPTION_ADD_STDCALL_UNDERSCORE + 1)
-#define OPTION_IDENTIFY_STRICT         (OPTION_USE_NUL_PREFIXED_IMPORT_TABLES + 1)
-#define OPTION_NO_LEADING_UNDERSCORE   (OPTION_IDENTIFY_STRICT + 1)
-#define OPTION_LEADING_UNDERSCORE      (OPTION_NO_LEADING_UNDERSCORE + 1)
+/* 150 isn't special; it's just an arbitrary non-ASCII char value.  */
+enum command_line_switch
+{
+  OPTION_EXPORT_ALL_SYMS = 150,
+  OPTION_NO_EXPORT_ALL_SYMS,
+  OPTION_EXCLUDE_SYMS,
+  OPTION_NO_DEFAULT_EXCLUDES,
+  OPTION_ADD_STDCALL_UNDERSCORE,
+  OPTION_USE_NUL_PREFIXED_IMPORT_TABLES,
+  OPTION_IDENTIFY_STRICT,
+  OPTION_NO_LEADING_UNDERSCORE,
+  OPTION_LEADING_UNDERSCORE,
+  OPTION_DETERMINISTIC_LIBRARIES,
+  OPTION_NON_DETERMINISTIC_LIBRARIES
+};
 
 static const struct option long_options[] =
 {
-  {"no-delete", no_argument, NULL, 'n'},
+  {"add-indirect", no_argument, NULL, 'a'},
+  {"add-stdcall-alias", no_argument, NULL, 'A'},
+  {"add-stdcall-underscore", no_argument, NULL, OPTION_ADD_STDCALL_UNDERSCORE},
+  {"add-underscore", no_argument, NULL, 'U'},
+  {"as", required_argument, NULL, 'S'},
+  {"as-flags", required_argument, NULL, 'f'},
+  {"base-file", required_argument, NULL, 'b'},
+  {"compat-implib", no_argument, NULL, 'C'},
+  {"def", required_argument, NULL, 'd'},     /* For compatibility with older versions.  */
+  {"deterministic-libraries", no_argument, NULL, OPTION_DETERMINISTIC_LIBRARIES},
   {"dllname", required_argument, NULL, 'D'},
-  {"no-idata4", no_argument, NULL, 'x'},
-  {"no-idata5", no_argument, NULL, 'c'},
-  {"use-nul-prefixed-import-tables", no_argument, NULL,
-   OPTION_USE_NUL_PREFIXED_IMPORT_TABLES},
-  {"output-exp", required_argument, NULL, 'e'},
-  {"output-def", required_argument, NULL, 'z'},
-  {"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL_SYMS},
-  {"no-export-all-symbols", no_argument, NULL, OPTION_NO_EXPORT_ALL_SYMS},
   {"exclude-symbols", required_argument, NULL, OPTION_EXCLUDE_SYMS},
-  {"no-default-excludes", no_argument, NULL, OPTION_NO_DEFAULT_EXCLUDES},
-  {"output-lib", required_argument, NULL, 'l'},
-  {"def", required_argument, NULL, 'd'}, /* for compatibility with older versions */
-  {"input-def", required_argument, NULL, 'd'},
-  {"add-underscore", no_argument, NULL, 'U'},
-  {"add-stdcall-underscore", no_argument, NULL, OPTION_ADD_STDCALL_UNDERSCORE},
-  {"no-leading-underscore", no_argument, NULL, OPTION_NO_LEADING_UNDERSCORE},
-  {"leading-underscore", no_argument, NULL, OPTION_LEADING_UNDERSCORE},
-  {"kill-at", no_argument, NULL, 'k'},
-  {"add-stdcall-alias", no_argument, NULL, 'A'},
+  {"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL_SYMS},
   {"ext-prefix-alias", required_argument, NULL, 'p'},
+  {"help", no_argument, NULL, 'h'},
   {"identify", required_argument, NULL, 'I'},
   {"identify-strict", no_argument, NULL, OPTION_IDENTIFY_STRICT},
-  {"verbose", no_argument, NULL, 'v'},
-  {"version", no_argument, NULL, 'V'},
-  {"help", no_argument, NULL, 'h'},
+  {"input-def", required_argument, NULL, 'd'},
+  {"kill-at", no_argument, NULL, 'k'},
+  {"leading-underscore", no_argument, NULL, OPTION_LEADING_UNDERSCORE},
   {"machine", required_argument, NULL, 'm'},
-  {"add-indirect", no_argument, NULL, 'a'},
-  {"base-file", required_argument, NULL, 'b'},
-  {"as", required_argument, NULL, 'S'},
-  {"as-flags", required_argument, NULL, 'f'},
   {"mcore-elf", required_argument, NULL, 'M'},
-  {"compat-implib", no_argument, NULL, 'C'},
-  {"temp-prefix", required_argument, NULL, 't'},
+  {"no-default-excludes", no_argument, NULL, OPTION_NO_DEFAULT_EXCLUDES},
+  {"no-delete", no_argument, NULL, 'n'},
+  {"no-export-all-symbols", no_argument, NULL, OPTION_NO_EXPORT_ALL_SYMS},
+  {"no-idata4", no_argument, NULL, 'x'},
+  {"no-idata5", no_argument, NULL, 'c'},
+  {"no-leading-underscore", no_argument, NULL, OPTION_NO_LEADING_UNDERSCORE},
+  {"non-deterministic-libraries", no_argument, NULL, OPTION_NON_DETERMINISTIC_LIBRARIES},
+  {"output-def", required_argument, NULL, 'z'},
   {"output-delaylib", required_argument, NULL, 'y'},
+  {"output-exp", required_argument, NULL, 'e'},
+  {"output-lib", required_argument, NULL, 'l'},
+  {"temp-prefix", required_argument, NULL, 't'},
+  {"use-nul-prefixed-import-tables", no_argument, NULL, OPTION_USE_NUL_PREFIXED_IMPORT_TABLES},
+  {"verbose", no_argument, NULL, 'v'},
+  {"version", no_argument, NULL, 'V'},
   {NULL,0,NULL,0}
 };
 
@@ -3924,6 +3944,12 @@ main (int ac, char **av)
        case 'y':
          delayimp_name = optarg;
          break;
+       case OPTION_DETERMINISTIC_LIBRARIES:
+         deterministic = true;
+         break;
+       case OPTION_NON_DETERMINISTIC_LIBRARIES:
+         deterministic = false;
+         break;
        default:
          usage (stderr, 1);
          break;
index 41f38f479f6d5b446fda0c5fc12ba3be5faf5a8c..f61a619ec786ac44742383866932c70a2cd2bc19 100644 (file)
@@ -4510,6 +4510,7 @@ dlltool [@option{-d}|@option{--input-def} @var{def-file-name}]
         [@option{-v}|@option{--verbose}]
         [@option{-h}|@option{--help}] [@option{-V}|@option{--version}]
         [@option{--no-leading-underscore}] [@option{--leading-underscore}]
+        [@option{--deterministic-libraries}] [@option{--non-deterministic-libraries}]
         [object-file @dots{}]
 @c man end
 @end smallexample
@@ -4629,6 +4630,14 @@ Specifies the name of the library file to be created by dlltool.
 @itemx --output-delaylib @var{filename}
 Specifies the name of the delay-import library file to be created by dlltool.
 
+@item --deterministic-libraries
+@itemx --non-deterministic-libraries
+When creating output libraries in response to either the
+@option{--output-lib} or @option{--output-delaylib} options either use
+the value of zero for any timestamps, user ids and group ids created
+(@option{--deterministic-libraries}) or the actual timestamps, user
+ids and group ids (@option{--non-deterministic-libraries}).
+
 @item --export-all-symbols
 Treat all global and weak defined symbols found in the input object
 files as symbols to be exported.  There is a small list of symbols which