From: Danny Smith Date: Thu, 9 Mar 2006 20:28:49 +0000 (+0000) Subject: * dlltool.c (add_stdcall_underscore): New flag. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=14288fdc16d91e5a1967e911e922e197a2f348c1;p=binutils-gdb.git * dlltool.c (add_stdcall_underscore): New flag. (xlate): Also add underscore to stdcall symbol if add_stdcall_underscore set. (usage): Document --add-stdcall-underscore option. (OPTION_ADD_STDCALL_UNDERSCORE): New define. (long_options): Use it for --add-stdcall-underscore option. (main): Handle it. * doc/binutils.texi: Document --add-stdcall-underscore option and differentiate from --add-underscore. --- diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 34ab9fe790c..f543b36ba51 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,15 @@ +2006-03-09 Danny Smith + + * dlltool.c (add_stdcall_underscore): New flag. + (xlate): Also add underscore to stdcall symbol if + add_stdcall_underscore set. + (usage): Document --add-stdcall-underscore option. + (OPTION_ADD_STDCALL_UNDERSCORE): New define. + (long_options): Use it for --add-stdcall-underscore option. + (main): Handle it. + * doc/binutils.texi: Document --add-stdcall-underscore option + and differentiate from --add-underscore. + 2006-03-06 Nathan Sidwell * readelf.c (get_machine_flags): Adjust. diff --git a/binutils/dlltool.c b/binutils/dlltool.c index d8bb03c0a8b..d6433083205 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -354,6 +354,7 @@ static char *dll_name; static int add_indirect = 0; static int add_underscore = 0; +static int add_stdcall_underscore = 0; static int dontdeltemps = 0; /* TRUE if we should export all symbols. Otherwise, we only export @@ -1994,7 +1995,9 @@ xlate (const char *name) { int lead_at = (*name == '@'); - if (add_underscore && !lead_at) + if (!lead_at && (add_underscore + || (add_stdcall_underscore + && strchr (name, '@')))) { char *copy = xmalloc (strlen (name) + 2); @@ -3046,7 +3049,8 @@ usage (FILE *file, int status) fprintf (file, _(" -b --base-file Read linker generated base file.\n")); fprintf (file, _(" -x --no-idata4 Don't generate idata$4 section.\n")); fprintf (file, _(" -c --no-idata5 Don't generate idata$5 section.\n")); - fprintf (file, _(" -U --add-underscore Add underscores to symbols in interface library.\n")); + fprintf (file, _(" -U --add-underscore Add underscores to all symbols in interface library.\n")); + fprintf (file, _(" --add-stdcall-underscore Add underscores to stdcall symbols in interface library.\n")); fprintf (file, _(" -k --kill-at Kill @ from exported names.\n")); fprintf (file, _(" -A --add-stdcall-alias Add aliases without @.\n")); fprintf (file, _(" -p --ext-prefix-alias Add aliases with .\n")); @@ -3071,6 +3075,7 @@ usage (FILE *file, int status) #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) static const struct option long_options[] = { @@ -3088,6 +3093,7 @@ static const struct option long_options[] = {"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}, {"kill-at", no_argument, NULL, 'k'}, {"add-stdcall-alias", no_argument, NULL, 'A'}, {"ext-prefix-alias", required_argument, NULL, 'p'}, @@ -3150,6 +3156,9 @@ main (int ac, char **av) case OPTION_NO_DEFAULT_EXCLUDES: do_default_excludes = FALSE; break; + case OPTION_ADD_STDCALL_UNDERSCORE: + add_stdcall_underscore = 1; + break; case 'x': no_idata4 = 1; break; diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index aaa0951229f..4a29433236e 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -3013,8 +3013,9 @@ dlltool [@option{-d}|@option{--input-def} @var{def-file-name}] [@option{--no-default-excludes}] [@option{-S}|@option{--as} @var{path-to-assembler}] [@option{-f}|@option{--as-flags} @var{options}] [@option{-D}|@option{--dllname} @var{name}] [@option{-m}|@option{--machine} @var{machine}] - [@option{-a}|@option{--add-indirect}] [@option{-U}|@option{--add-underscore}] [@option{-k}|@option{--kill-at}] - [@option{-A}|@option{--add-stdcall-alias}] + [@option{-a}|@option{--add-indirect}] + [@option{-U}|@option{--add-underscore}] [@option{--add-stdcall-underscore}] + [@option{-k}|@option{--kill-at}] [@option{-A}|@option{--add-stdcall-alias}] [@option{-p}|@option{--ext-prefix-alias} @var{prefix}] [@option{-x}|@option{--no-idata4}] [@option{-c}|@option{--no-idata5}] [@option{-i}|@option{--interwork}] [@option{-n}|@option{--nodelete}] [@option{-t}|@option{--temp-prefix} @var{prefix}] @@ -3190,7 +3191,14 @@ means! @item -U @itemx --add-underscore Specifies that when @command{dlltool} is creating the exports file it -should prepend an underscore to the names of the exported functions. +should prepend an underscore to the names of @emph{all} exported symbols. + +@item --add-stdcall-underscore +Specifies that when @command{dlltool} is creating the exports file it +should prepend an underscore to the names of exported @emph{stdcall} +functions. Variable names and non-stdcall function names are not modified. +This option is useful when creating GNU-compatible import libs for third +party DLLs that were built with MS-Windows tools. @item -k @itemx --kill-at