This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] to dlltool: new option NO_DEMANGLE_DEF_NAMES



When producing dll's with ld -shared, ld chokes on def files produced by
dlltool from C++ code. Comments (marked with ';') are okay if at start of
line but not elsewhere. They appear to interpreted as '\n' and ld tries
unsuccessfully to locate the demangled name that follows ';' as a comment.
The place to fix this properly would be in ld's deffile.y.  Unfortunately,
I am a stranger to yacc, so I am proposing a new option to dlltool to output
def files without the demangled C++ names as comments.

ChangeLog

2001-05-23  Danny Smith  <danny_r_smith_2001@yahoo.co.nz>

	* dlltool.c	(demangle_def_names): New static variable.
	(gen_def_file): Use.
	(OPTION_NO_DEMANGLE_DEF_NAMES): Define.
	(long_options[]): New --no-demangle-defs option.
	(usage): Document.
	(main): Handle.
	
--- dlltool.c.orig	Wed May 23 20:56:36 2001
+++ dlltool.c	Wed May 23 21:21:02 2001
@@ -372,6 +372,9 @@ static boolean do_default_excludes=true;
 /* Default symbols to exclude when exporting all the symbols.  */
 static const char *default_excludes = "DllMain@12,DllEntryPoint@0,impure_ptr";
 
+/* Put demangled C++ names into output def file (default) */
+static boolean demangle_def_names = true;
+
 /* True if we should add __imp_<SYMBOL> to import libraries for backward 
    compatibility to old Cygwin releases.  */
 static boolean create_compat_implib;
@@ -1611,8 +1614,10 @@ gen_def_file ()
   for (i = 0, exp = d_exports; exp; i++, exp = exp->next)
     {
       char *quote = strchr (exp->name, '.') ? "\"" : "";
-      char *res = cplus_demangle (exp->internal_name, DMGL_ANSI |
DMGL_PARAMS);
 
+      char *res = (demangle_def_names ? 
+        cplus_demangle (exp->internal_name, DMGL_ANSI | DMGL_PARAMS)
+        : NULL);
       if (strcmp (exp->name, exp->internal_name) == 0)
         {
 
@@ -3149,6 +3154,7 @@ usage (file, status)
   fprintf (file, _("      --no-export-all-symbols  Only export listed
symbols\n"));
   fprintf (file, _("      --exclude-symbols <list> Don't export <list>\n"));
   fprintf (file, _("      --no-default-excludes  Clear default exclude
symbols\n"));
+  fprintf (file, _("      --no-demangle-defs     Don't output demangled names
to def file\n"));
   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"));
@@ -3174,6 +3180,7 @@ usage (file, 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_NO_DEMANGLE_DEF_NAMES (OPTION_NO_DEFAULT_EXCLUDES + 1)
 
 static const struct option long_options[] =
 {
@@ -3187,6 +3194,7 @@ static const struct option long_options[
   {"no-export-all-symbols", no_argument, NULL, OPTION_NO_EXPORT_ALL_SYMS},
   {"exclude-symbols", required_argument, NULL, OPTION_EXCLUDE_SYMS},
   {"no-default-excludes", no_argument, NULL, OPTION_NO_DEFAULT_EXCLUDES},
+  {"no-demangle-defs", no_argument, NULL, OPTION_NO_DEMANGLE_DEF_NAMES},
   {"output-lib", required_argument, NULL, 'l'},
   {"def", required_argument, NULL, 'd'}, /* for compatiblity with older
versions */
   {"input-def", required_argument, NULL, 'd'},
@@ -3245,6 +3253,9 @@ main (ac, av)
 	  break;
 	case OPTION_NO_DEFAULT_EXCLUDES:
 	  do_default_excludes = false;
+	  break;
+	case OPTION_NO_DEMANGLE_DEF_NAMES:
+	  demangle_def_names = false;
 	  break;
 	case 'x':
 	  no_idata4 = 1;
 



_____________________________________________________________________________
http://messenger.yahoo.com.au - Yahoo! Messenger
- Voice chat, mail alerts, stock quotes and favourite news and lots more!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]