Index: src/binutils/dlltool.c =================================================================== --- src.orig/binutils/dlltool.c 2009-10-23 16:47:36.000000000 +0200 +++ src/binutils/dlltool.c 2009-10-26 15:49:15.296692100 +0100 @@ -394,6 +394,7 @@ static int add_indirect = 0; static int add_underscore = 0; static int add_stdcall_underscore = 0; +static int leading_underscore = -1; static int dontdeltemps = 0; /* TRUE if we should export all symbols. Otherwise, we only export @@ -936,7 +937,7 @@ case M386: case MX86: /* Symbol names starting with ? do not have a leading underscore. */ - if (name && *name == '?') + if ((name && *name == '?') || leading_underscore == 0) break; else return "_"; @@ -1488,7 +1489,8 @@ if (*exclude_string == '@') sprintf (new_exclude->string, "%s", exclude_string); else - sprintf (new_exclude->string, "_%s", exclude_string); + sprintf (new_exclude->string, "%s%s", (!leading_underscore ? "" : "_"), + exclude_string); new_exclude->next = excludes; excludes = new_exclude; @@ -2100,10 +2102,11 @@ cygwin releases. */ if (create_compat_implib) fprintf (f, "\t%s\t__imp_%s\n", ASM_GLOBAL, exp->name); - fprintf (f, "\t%s\t_imp__%s\n", ASM_GLOBAL, exp->name); + fprintf (f, "\t%s\t_imp_%s%s\n", ASM_GLOBAL, + (!leading_underscore ? "" : "_"), exp->name); if (create_compat_implib) fprintf (f, "__imp_%s:\n", exp->name); - fprintf (f, "_imp__%s:\n", exp->name); + fprintf (f, "_imp_%s%s:\n", (!leading_underscore ? "" : "_"), exp->name); fprintf (f, "\t%s\t%s\n", ASM_LONG, exp->name); } } @@ -2182,10 +2185,11 @@ xlate (const char *name) { int lead_at = (*name == '@'); + int is_stdcall = (!lead_at && strchr (name, '@') != NULL); if (!lead_at && (add_underscore - || (add_stdcall_underscore - && strchr (name, '@')))) + || (!is_stdcall && leading_underscore == 1) + || (add_stdcall_underscore && is_stdcall))) { char *copy = xmalloc (strlen (name) + 2); @@ -3872,6 +3876,8 @@ fprintf (file, _(" --use-nul-prefixed-import-tables Use zero prefixed idata$4 and idata$5.\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, _(" --no-leading-underscore All symbols shouldn't be prefixed by an underscore.\n")); + fprintf (file, _(" --leading-underscore All symbols should be prefixed by an underscore.\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")); @@ -3904,6 +3910,8 @@ #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) static const struct option long_options[] = { @@ -3924,6 +3932,8 @@ {"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'}, {"ext-prefix-alias", required_argument, NULL, 'p'}, @@ -3995,6 +4005,12 @@ case OPTION_ADD_STDCALL_UNDERSCORE: add_stdcall_underscore = 1; break; + case OPTION_NO_LEADING_UNDERSCORE: + leading_underscore = 0; + break; + case OPTION_LEADING_UNDERSCORE: + leading_underscore = 1; + break; case OPTION_IDENTIFY_STRICT: identify_strict = 1; break; Index: src/binutils/doc/binutils.texi =================================================================== --- src.orig/binutils/doc/binutils.texi 2009-10-23 16:47:36.000000000 +0200 +++ src/binutils/doc/binutils.texi 2009-10-26 15:44:41.920692100 +0100 @@ -3509,6 +3509,7 @@ [@option{-n}|@option{--nodelete}] [@option{-t}|@option{--temp-prefix} @var{prefix}] [@option{-v}|@option{--verbose}] [@option{-h}|@option{--help}] [@option{-V}|@option{--version}] + [@option{--no-leading-underscore}] [@option{--leading-underscore}] [object-file @dots{}] @c man end @end smallexample @@ -3697,6 +3698,10 @@ Specifies that when @command{dlltool} is creating the exports file it should prepend an underscore to the names of @emph{all} exported symbols. +@item --no-leading-underscore +@item --leading-underscore +Specifies that standard symbols should forced to be prefix, or not. + @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}