From 607dea976448c7af523547e62d37eba4975c3f94 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 12 Jul 2004 17:07:55 +0000 Subject: [PATCH] dlltool.c (ext_prefix_alias): New global variable. (make_one_lib_file): Add aliases with prefixes for external and import definitions. (usage): Document -p option. (long_options): Add --ext-prefix-alias option. (main): Handle -p. * doc/binutils.texi: Document new switch. * NEWS: Mention new switch. --- binutils/ChangeLog | 11 +++++ binutils/NEWS | 5 +++ binutils/dlltool.c | 49 ++++++++++++++++++--- binutils/doc/binutils.texi | 15 +++++-- binutils/testsuite/ChangeLog | 5 +++ binutils/testsuite/binutils-all/dlltool.exp | 12 +++++ 6 files changed, 88 insertions(+), 9 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index b54692e19e3..2f1b7337eaa 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,14 @@ +2004-07-12 Aaron W. LaFramboise + + * dlltool.c (ext_prefix_alias): New global variable. + (make_one_lib_file): Add aliases with prefixes for external + and import definitions. + (usage): Document -p option. + (long_options): Add --ext-prefix-alias option. + (main): Handle -p. + * doc/binutils.texi: Document new switch. + * NEWS: Mention new switch. + 2004-07-09 Aaron W. LaFramboise * binutils/dlltool.c (asm_prefix): Add parameter: name. diff --git a/binutils/NEWS b/binutils/NEWS index a72826ef873..a753312c57a 100644 --- a/binutils/NEWS +++ b/binutils/NEWS @@ -1,5 +1,10 @@ -*- text -*- +* dlltool has a switch "--ext-prefix-alias " to generate additional + import and export symbols with prepended to them. + +Changes in 2.15: + * objcopy and strip can now take wildcard patterns in symbol names specified on the command line provided that the --wildcard switch is used to enable them. diff --git a/binutils/dlltool.c b/binutils/dlltool.c index 91539102daf..2f829287b9a 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -382,6 +382,7 @@ extern char * program_name; static int machine; static int killat; static int add_stdcall_alias; +static const char *ext_prefix_alias; static int verbose; static FILE *output_def; static FILE *base_file; @@ -2247,6 +2248,7 @@ make_one_lib_file (export_type *exp, int i) asymbol * exp_label; asymbol * iname = 0; asymbol * iname2; + asymbol * iname2_pre = 0; asymbol * iname_lab; asymbol ** iname_lab_pp; asymbol ** iname_pp; @@ -2260,7 +2262,6 @@ make_one_lib_file (export_type *exp, int i) #endif asymbol * ptrs[NSECS + 4 + EXTRA + 1]; flagword applicable; - char * outname = xmalloc (strlen (TMP_STUB) + 10); int oidx = 0; @@ -2290,6 +2291,7 @@ make_one_lib_file (export_type *exp, int i) for (i = 0; i < NSECS; i++) { sinfo *si = secdata + i; + if (si->id != i) abort(); si->sec = bfd_make_section_old_way (abfd, si->name); @@ -2336,6 +2338,23 @@ make_one_lib_file (export_type *exp, int i) bfd_coff_set_symbol_class (abfd, exp_label, C_THUMBEXTFUNC); #endif ptrs[oidx++] = exp_label; + + if (ext_prefix_alias) + { + asymbol * exp_label_pre; + + exp_label_pre = bfd_make_empty_symbol (abfd); + exp_label_pre->name + = make_imp_label (ext_prefix_alias, exp->name); + exp_label_pre->section = exp_label->section; + exp_label_pre->flags = exp_label->flags; + exp_label_pre->value = exp_label->value; +#ifdef DLLTOOL_ARM + if (machine == MTHUMB) + bfd_coff_set_symbol_class (abfd, exp_label, C_THUMBEXTFUNC); +#endif + ptrs[oidx++] = exp_label_pre; + } } /* Generate imp symbols with one underscore for Microsoft @@ -2356,10 +2375,23 @@ make_one_lib_file (export_type *exp, int i) iname2->flags = BSF_GLOBAL; iname2->value = 0; - iname_lab = bfd_make_empty_symbol(abfd); + if (ext_prefix_alias) + { + char *pre_name; + + iname2_pre = bfd_make_empty_symbol (abfd); + pre_name = xmalloc (strlen (ext_prefix_alias) + 7); + sprintf(pre_name, "__imp_%s", ext_prefix_alias); + iname2_pre->name = make_imp_label (pre_name, exp->name); + iname2_pre->section = iname2->section; + iname2_pre->flags = iname2->flags; + iname2_pre->value = iname2->value; + } + + iname_lab = bfd_make_empty_symbol (abfd); iname_lab->name = head_label; - iname_lab->section = (asection *)&bfd_und_section; + iname_lab->section = (asection *) &bfd_und_section; iname_lab->flags = 0; iname_lab->value = 0; @@ -2367,6 +2399,8 @@ make_one_lib_file (export_type *exp, int i) if (create_compat_implib) ptrs[oidx++] = iname; ptrs[oidx++] = iname2; + if (ext_prefix_alias) + ptrs[oidx++] = iname2_pre; iname_lab_pp = ptrs + oidx; ptrs[oidx++] = iname_lab; @@ -3129,6 +3163,7 @@ usage (FILE *file, int status) fprintf (file, _(" -U --add-underscore Add underscores to 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")); fprintf (file, _(" -S --as Use for assembler.\n")); fprintf (file, _(" -f --as-flags Pass to the assembler.\n")); fprintf (file, _(" -C --compat-implib Create backward compatible import library.\n")); @@ -3168,6 +3203,7 @@ static const struct option long_options[] = {"add-underscore", no_argument, NULL, 'U'}, {"kill-at", no_argument, NULL, 'k'}, {"add-stdcall-alias", no_argument, NULL, 'A'}, + {"ext-prefix-alias", required_argument, NULL, 'p'}, {"verbose", no_argument, NULL, 'v'}, {"version", no_argument, NULL, 'V'}, {"help", no_argument, NULL, 'h'}, @@ -3204,9 +3240,9 @@ main (int ac, char **av) while ((c = getopt_long (ac, av, #ifdef DLLTOOL_MCORE_ELF - "m:e:l:aD:d:z:b:xcCuUkAS:f:nvVHhM:L:F:", + "m:e:l:aD:d:z:b:xp:cCuUkAS:f:nvVHhM:L:F:", #else - "m:e:l:aD:d:z:b:xcCuUkAS:f:nvVHh", + "m:e:l:aD:d:z:b:xp:cCuUkAS:f:nvVHh", #endif long_options, 0)) != EOF) @@ -3281,6 +3317,9 @@ main (int ac, char **av) case 'A': add_stdcall_alias = 1; break; + case 'p': + ext_prefix_alias = optarg; + break; case 'd': def_file = optarg; break; diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index c27c627094a..f92252d2f6f 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -1,6 +1,6 @@ \input texinfo @c -*- Texinfo -*- @setfilename binutils.info -@c Copyright 2001, 2002, 2003 Free Software Foundation, Inc. +@c Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. @include config.texi @@ -30,7 +30,7 @@ END-INFO-DIR-ENTRY @ifinfo @c man begin COPYRIGHT Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, -2001, 2002, 2003 Free Software Foundation, Inc. +2001, 2002, 2003, 2004 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 @@ -55,7 +55,7 @@ notice identical to this one except for the removal of this paragraph @c "objdump", "nm", "size", "strings", "strip", "readelf" and "ranlib". @c @c Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, -@c 2002, 2003 Free Software Foundation, Inc. +@c 2002, 2003, 2004 Free Software Foundation, Inc. @c @c This text may be freely distributed under the terms of the GNU @c Free Documentation License. @@ -81,7 +81,7 @@ notice identical to this one except for the removal of this paragraph @vskip 0pt plus 1filll Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 97, 1998, 2000, 2001, -2002, 2003 Free Software Foundation, Inc. +2002, 2003, 2004 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 @@ -2866,6 +2866,7 @@ dlltool [@option{-d}|@option{--input-def} @var{def-file-name}] [@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}] [@option{-v}|@option{--verbose}] @@ -3055,6 +3056,12 @@ Specifies that when @command{dlltool} is creating the exports file it should add aliases for stdcall symbols without @samp{@@ } in addition to the symbols with @samp{@@ }. +@item -p +@itemx --ext-prefix-alias @var{prefix} +Causes @command{dlltool} to create external aliases for all DLL +imports with the specified prefix. The aliases are created for both +external and import symbols with no leading underscore. + @item -x @itemx --no-idata4 Specifies that when @command{dlltool} is creating the exports and library diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog index 8f3473a061b..6e1d33d1561 100644 --- a/binutils/testsuite/ChangeLog +++ b/binutils/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-07-12 Nick Clifton + + * binutils-all/dlltool.exp: Check that the -p switch is not + rejected. + 2004-07-09 Andreas Schwab * binutils-all/m68k/movem.s: New file. diff --git a/binutils/testsuite/binutils-all/dlltool.exp b/binutils/testsuite/binutils-all/dlltool.exp index f061ab8d3ac..ba758df81a3 100644 --- a/binutils/testsuite/binutils-all/dlltool.exp +++ b/binutils/testsuite/binutils-all/dlltool.exp @@ -45,3 +45,15 @@ if ![string match "" $err] then { } pass "dlltool (fastcall export)" + +verbose "$DLLTOOL -p foo -d $srcdir/$subdir/fastcall.def" 1 +catch "exec $DLLTOOL -p foo -d $srcdir/$subdir/fastcall.def" err + +if ![string match "" $err] then { + send_log "$err\n" + verbose "$err" 1 + fail "dlltool (aliased export)" + continue +} + +pass "dlltool (aliased export)" -- 2.30.2