* [Patch] New --add-stdcall-underscore compatibilty option for dlltool built import libs
@ 2006-03-07 9:44 Danny Smith
2006-03-09 17:10 ` Nick Clifton
0 siblings, 1 reply; 2+ messages in thread
From: Danny Smith @ 2006-03-07 9:44 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]
Hello
DLLs built with MS-Windows tools use different default rules for the
naming of __stdcall function names in export table: for stdcall symbols the
string in
the dll's export table has the assembler prefix '_' prepended, while for
cdecl symbols or variable names, the underscore prefix is stripped. In
contrast, in dlls built with GNU tools, the assembler underscore prefix
is stripped from all symbols by default.
The -U (--add-underscore) dlltool option is not generally suitable for
fixing up this incompatibility when creating GNU-compatible import libs
for 3rd party dll's that were built with MS tools, since it adds
underscores to all symbols, not just __stdcall ones.
The attached patch adds a new long option to prepend underscores to stdcall
symbols only.
binutils/ChangeLog
2006-03-07 Danny Smith <dannysmith@users.sourceforge.net>
* 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.
[-- Attachment #2: add-stdcall-underscore.diff --]
[-- Type: text/plain, Size: 6522 bytes --]
Index: dlltool.c
===================================================================
RCS file: /cvs/src/src/binutils/dlltool.c,v
retrieving revision 1.67
diff -c -3 -p -r1.67 dlltool.c
*** dlltool.c 3 Oct 2005 19:37:44 -0000 1.67
--- dlltool.c 7 Mar 2006 09:32:26 -0000
*************** static char *dll_name;
*** 354,359 ****
--- 354,360 ----
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
*************** xlate (const char *name)
*** 1994,2000 ****
{
int lead_at = (*name == '@');
! if (add_underscore && !lead_at)
{
char *copy = xmalloc (strlen (name) + 2);
--- 1995,2003 ----
{
int lead_at = (*name == '@');
! if (!lead_at && (add_underscore
! || (add_stdcall_underscore
! && strchr (name, '@'))))
{
char *copy = xmalloc (strlen (name) + 2);
*************** usage (FILE *file, int status)
*** 3046,3052 ****
fprintf (file, _(" -b --base-file <basefile> 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, _(" -k --kill-at Kill @<n> from exported names.\n"));
fprintf (file, _(" -A --add-stdcall-alias Add aliases without @<n>.\n"));
fprintf (file, _(" -p --ext-prefix-alias <prefix> Add aliases with <prefix>.\n"));
--- 3049,3056 ----
fprintf (file, _(" -b --base-file <basefile> 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 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 @<n> from exported names.\n"));
fprintf (file, _(" -A --add-stdcall-alias Add aliases without @<n>.\n"));
fprintf (file, _(" -p --ext-prefix-alias <prefix> Add aliases with <prefix>.\n"));
*************** usage (FILE *file, int status)
*** 3071,3076 ****
--- 3075,3081 ----
#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[] =
{
*************** static const struct option long_options[
*** 3088,3093 ****
--- 3093,3099 ----
{"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'},
*************** main (int ac, char **av)
*** 3150,3155 ****
--- 3156,3164 ----
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;
Index: doc/binutils.texi
===================================================================
RCS file: /cvs/src/src/binutils/doc/binutils.texi,v
retrieving revision 1.87
diff -c -3 -p -r1.87 binutils.texi
*** doc/binutils.texi 28 Feb 2006 16:09:01 -0000 1.87
--- doc/binutils.texi 7 Mar 2006 09:32:38 -0000
*************** dlltool [@option{-d}|@option{--input-def
*** 3013,3020 ****
[@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{-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}]
--- 3013,3021 ----
[@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{--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}]
*************** means!
*** 3190,3196 ****
@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.
@item -k
@itemx --kill-at
--- 3191,3204 ----
@item -U
@itemx --add-underscore
Specifies that when @command{dlltool} is creating the exports file it
! 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Patch] New --add-stdcall-underscore compatibilty option for dlltool built import libs
2006-03-07 9:44 [Patch] New --add-stdcall-underscore compatibilty option for dlltool built import libs Danny Smith
@ 2006-03-09 17:10 ` Nick Clifton
0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2006-03-09 17:10 UTC (permalink / raw)
To: Danny Smith; +Cc: binutils
Hi Danny,
> binutils/ChangeLog
>
> 2006-03-07 Danny Smith <dannysmith@users.sourceforge.net>
>
> * 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.
Approved - please apply.
Cheers
Nick
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-03-09 17:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-07 9:44 [Patch] New --add-stdcall-underscore compatibilty option for dlltool built import libs Danny Smith
2006-03-09 17:10 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).