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]
Other format: [Raw text]

[PATCH/pei-386] dlltool-produced def files vs ld


Hi,

When parsing .def files, ld accepts comments (marked by a lead ';') only
if they are at start of a line. 
This is consistent with MS tools and def file format (and MS scripts in
general).

However, the def files produced by dlltool --output-def puts comments
showing the demangled C++ name, _following_ the exported symbol. This means
they can not be used by ld without first passing through a sed script (or cut)
to get rid of the comment

The following fixes, by putting the comment on their own line, preceding
the mangled symbol name, so that this:

; old-dlltool --output-def old.def dllclass.o
EXPORTS
	_ZNK8DllClass14virtual_methodEv @ 1 ; DllClass::virtual_method() const
	_ZN8DllClass9instancesE @ 2 DATA ; DllClass::instances
	_ZN8DllClassC1Ei @ 3 ; DllClass::DllClass(int)
etc.

becomes this:

; new-dlltool --output-def new.def dllclass.o
EXPORTS
;	DllClass::virtual_method() const
	_ZNK8DllClass14virtual_methodEv @ 1
;	DllClass::instances
	_ZN8DllClass9instancesE @ 2 DATA
;	DllClass::DllClass(int)
	_ZN8DllClassC1Ei @ 3
etc,

This is acceptable as input to ld.exe.

It also has a human-readability advantage when outputting very long
C++ symbols names


The other option (which could be combined with this patch) would be to
add a new switch --no-demangled-defs which would eliminate the comments

ChangeLog

2003-03-22  Danny Smith  <dannysmith at users dot sourceforge,net>

	* dlltool.c (gen_def_file): Put demangled name comments on
	own line preceding export name.


Index: dlltool.c
===================================================================
RCS file: /cvs/src/src/binutils/dlltool.c,v
retrieving revision 1.39
diff -c -3 -p -r1.39 dlltool.c
*** dlltool.c	20 Feb 2003 03:31:42 -0000	1.39
--- dlltool.c	21 Mar 2003 20:19:43 -0000
*************** gen_def_file ()
*** 1670,1692 ****
        char *quote = strchr (exp->name, '.') ? "\"" : "";
        char *res = cplus_demangle (exp->internal_name, DMGL_ANSI |
DMGL_PARAMS);
  
        if (strcmp (exp->name, exp->internal_name) == 0)
  	{
  
! 	  fprintf (output_def, "\t%s%s%s @ %d%s%s ; %s\n",
  		   quote,
  		   exp->name,
  		   quote,
  		   exp->ordinal,
  		   exp->noname ? " NONAME" : "",
! 		   exp->data ? " DATA" : "",
! 		   res ? res : "");
  	}
        else
  	{
  	  char *quote1 = strchr (exp->internal_name, '.') ? "\"" : "";
  	  /* char *alias =  */
! 	  fprintf (output_def, "\t%s%s%s = %s%s%s @ %d%s%s ; %s\n",
  		   quote,
  		   exp->name,
  		   quote,
--- 1670,1697 ----
        char *quote = strchr (exp->name, '.') ? "\"" : "";
        char *res = cplus_demangle (exp->internal_name, DMGL_ANSI |
DMGL_PARAMS);
  
+       if (res)
+ 	{
+  	  fprintf (output_def,";\t%s\n", res);
+ 	  free (res);
+ 	}
+ 
        if (strcmp (exp->name, exp->internal_name) == 0)
  	{
  
! 	  fprintf (output_def, "\t%s%s%s @ %d%s%s\n",
  		   quote,
  		   exp->name,
  		   quote,
  		   exp->ordinal,
  		   exp->noname ? " NONAME" : "",
! 		   exp->data ? " DATA" : "");
  	}
        else
  	{
  	  char *quote1 = strchr (exp->internal_name, '.') ? "\"" : "";
  	  /* char *alias =  */
! 	  fprintf (output_def, "\t%s%s%s = %s%s%s @ %d%s%s\n",
  		   quote,
  		   exp->name,
  		   quote,
*************** gen_def_file ()
*** 1695,1705 ****
  		   quote1,
  		   exp->ordinal,
  		   exp->noname ? " NONAME" : "",
! 		   exp->data ? " DATA" : "",
! 		   res ? res : "");
  	}
-       if (res)
- 	free (res);
      }
  
    inform (_("Added exports to output file"));
--- 1700,1707 ----
  		   quote1,
  		   exp->ordinal,
  		   exp->noname ? " NONAME" : "",
! 		   exp->data ? " DATA" : "");
  	}
      }
  
    inform (_("Added exports to output file"));

http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.


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