diff options
author | Kai Tietz <kai.tietz@onevision.com> | 2009-10-28 17:21:36 +0000 |
---|---|---|
committer | Kai Tietz <kai.tietz@onevision.com> | 2009-10-28 17:21:36 +0000 |
commit | 36d21de541788f5ceae44d8250e33af906af6b14 (patch) | |
tree | 84dfc71e7c64b3fa9ce88daadd2483c8796e7dba /binutils | |
parent | 0bd7136a923213847d3c3c0b0836c685d3783276 (diff) | |
download | gdb-36d21de541788f5ceae44d8250e33af906af6b14.zip gdb-36d21de541788f5ceae44d8250e33af906af6b14.tar.gz gdb-36d21de541788f5ceae44d8250e33af906af6b14.tar.bz2 |
2009-10-28 Kai Tietz <kai.tietz@onevision.com>
* dlltool.c (leading_underscore): New local variable.
(asm_prefix): Interpret leading_underscore.
(xlate): Likewise.
(add_excludes): Use leading_underscore for making
symbol name.
(gen_exp_file): Use leading_underscore for internal
_imp_ symbols.
(usage): Add display of --no-leading-underscore and
--leading-underscore option.
(OPTION_NO_LEADING_UNDERSCORE): New.
(OPTION_LEADING_UNDERSCORE): New.
(long_options): Add --no-leading-underscore and
--leading-underscore option.
(main): Handle new options.
* doc/binutils.text: Add documentation of the options
--no-leading-underscore and --leading-underscore.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 19 | ||||
-rw-r--r-- | binutils/dlltool.c | 31 | ||||
-rw-r--r-- | binutils/doc/binutils.texi | 6 |
3 files changed, 50 insertions, 6 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index eeeb615..e23e18f 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,22 @@ +2009-10-28 Kai Tietz <kai.tietz@onevision.com> + + * dlltool.c (leading_underscore): New local variable. + (asm_prefix): Interpret leading_underscore. + (xlate): Likewise. + (add_excludes): Use leading_underscore for making + symbol name. + (gen_exp_file): Use leading_underscore for internal + _imp_ symbols. + (usage): Add display of --no-leading-underscore and + --leading-underscore option. + (OPTION_NO_LEADING_UNDERSCORE): New. + (OPTION_LEADING_UNDERSCORE): New. + (long_options): Add --no-leading-underscore and + --leading-underscore option. + (main): Handle new options. + * doc/binutils.text: Add documentation of the options + --no-leading-underscore and --leading-underscore. + 2009-10-23 Kai Tietz <kai.tietz@onevision.com> * deflex.l: Allow '<' and '>' in ID names. diff --git a/binutils/dlltool.c b/binutils/dlltool.c index 4c9d2ec..72a4a7e 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -394,6 +394,11 @@ static char *dll_name; static int add_indirect = 0; static int add_underscore = 0; static int add_stdcall_underscore = 0; +/* This variable can hold three different values. The value + -1 (default) means that default underscoring should be used, + zero means that no underscoring should be done, and one + indicates that underscoring should be done. */ +static int leading_underscore = -1; static int dontdeltemps = 0; /* TRUE if we should export all symbols. Otherwise, we only export @@ -936,7 +941,7 @@ asm_prefix (int machine, const char *name) 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 +1493,8 @@ add_excludes (const char *new_excludes) 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 +2106,11 @@ gen_exp_file (void) 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 +2189,10 @@ static const char * 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, '@')))) + || (add_stdcall_underscore && is_stdcall))) { char *copy = xmalloc (strlen (name) + 2); @@ -3872,6 +3879,8 @@ usage (FILE *file, int status) 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 @<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")); @@ -3904,6 +3913,8 @@ usage (FILE *file, int status) #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 +3935,8 @@ static const struct option long_options[] = {"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 +4008,12 @@ main (int ac, char **av) 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; diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index cb48014..84b63d7 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -3509,6 +3509,7 @@ dlltool [@option{-d}|@option{--input-def} @var{def-file-name}] [@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,11 @@ means! 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 whether standard symbol should be forced to be prefixed, 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} |