From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2124) id B12663858D3C; Tue, 23 Aug 2022 08:55:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B12663858D3C Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nick Clifton To: bfd-cvs@sourceware.org Subject: [binutils-gdb] Add an option to dlltool to allow the creation of deterministic libraries. X-Act-Checkin: binutils-gdb X-Git-Author: Nick Clifton X-Git-Refname: refs/heads/master X-Git-Oldrev: 179390a3758768968b0c710292b3e166040d2520 X-Git-Newrev: 25ee24d990d6beb3fb01c673fcf13e0ea1522c5b Message-Id: <20220823085533.B12663858D3C@sourceware.org> Date: Tue, 23 Aug 2022 08:55:33 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Aug 2022 08:55:33 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D25ee24d990d6= beb3fb01c673fcf13e0ea1522c5b commit 25ee24d990d6beb3fb01c673fcf13e0ea1522c5b Author: Nick Clifton Date: Tue Aug 23 09:54:52 2022 +0100 Add an option to dlltool to allow the creation of deterministic librari= es. =20 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. Diff: --- binutils/ChangeLog | 13 ++++++ binutils/NEWS | 5 +++ binutils/dlltool.c | 102 ++++++++++++++++++++++++++++-------------= ---- binutils/doc/binutils.texi | 9 ++++ 4 files changed, 91 insertions(+), 38 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index e01db7db521..04ef77c5530 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,16 @@ +2022-08-23 Nick Clifton + + 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 =20 * readelf.c (check_magic_number): New function. Checks the magic diff --git a/binutils/NEWS b/binutils/NEWS index 4fdf1c3b4e8..8c2c416c17e 100644 --- a/binutils/NEWS +++ b/binutils/NEWS @@ -1,5 +1,10 @@ -*- text -*- =20 +* 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 op= tions + are used the default is whatever was set when the binutils were configur= ed. + =20 Changes in 2.39: =20 * Add --no-weak/-W option to nm to make it ignore weak symbols. diff --git a/binutils/dlltool.c b/binutils/dlltool.c index e2af2084700..b4ac842212a 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -356,6 +356,7 @@ static char *imp_name; static char *delayimp_name; static char *identify_imp_name; static bool identify_strict; +static bool deterministic =3D DEFAULT_AR_DETERMINISTIC; =20 /* 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 =3D 1; outarch->is_thin_archive =3D 0; =20 + if (deterministic) + outarch->flags |=3D 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 Generate an export file.\= n")); fprintf (file, _(" -l --output-lib Generate an interface lib= rary.\n")); fprintf (file, _(" -y --output-delaylib Create a delay-impor= t 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 a= nd uids/gids in output libraries\n")); + else + fprintf (file, _(" Use actual timestamps a= nd uids/gids in output libraries (default)\n")); fprintf (file, _(" -a --add-indirect Add dll indirects to expo= rt file.\n")); fprintf (file, _(" -D --dllname Name of input dll to put = into interface lib.\n")); fprintf (file, _(" -d --input-def Name of .def file to be r= ead in.\n")); @@ -3714,55 +3728,61 @@ usage (FILE *file, int status) exit (status); } =20 -#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 =3D 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 +}; =20 static const struct option long_options[] =3D { - {"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_UNDERSC= ORE}, + {"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 old= er versions. */ + {"deterministic-libraries", no_argument, NULL, OPTION_DETERMINISTIC_LIBR= ARIES}, {"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 v= ersions */ - {"input-def", required_argument, NULL, 'd'}, - {"add-underscore", no_argument, NULL, 'U'}, - {"add-stdcall-underscore", no_argument, NULL, OPTION_ADD_STDCALL_UNDERSC= ORE}, - {"no-leading-underscore", no_argument, NULL, OPTION_NO_LEADING_UNDERSCOR= E}, - {"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_UNDERSCOR= E}, + {"non-deterministic-libraries", no_argument, NULL, OPTION_NON_DETERMINIS= TIC_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_PRE= FIXED_IMPORT_TABLES}, + {"verbose", no_argument, NULL, 'v'}, + {"version", no_argument, NULL, 'V'}, {NULL,0,NULL,0} }; =20 @@ -3924,6 +3944,12 @@ main (int ac, char **av) case 'y': delayimp_name =3D optarg; break; + case OPTION_DETERMINISTIC_LIBRARIES: + deterministic =3D true; + break; + case OPTION_NON_DETERMINISTIC_LIBRARIES: + deterministic =3D false; + break; default: usage (stderr, 1); break; diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index 41f38f479f6..f61a619ec78 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -4510,6 +4510,7 @@ dlltool [@option{-d}|@option{--input-def} @var{def-fi= le-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 dllto= ol. =20 +@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