Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 02 Nov 1997 22:09:10 -0500
From:      Jay Sachs <sachs@bull.cs.williams.edu>
To:        egcs-bugs@cygnus.com, freebsd-questions@freebsd.org
Subject:   patch for egcs -frepo to work with FreeBSD ld
Message-ID:  <rz8yb36smg9.fsf@cs.williams.edu>

next in thread | raw e-mail | index | archive | help
--Multipart_Sun_Nov__2_22:09:10_1997-1
Content-Type: text/plain; charset=US-ASCII

After a little bit of experimenting, I figured out how FreeBSD's ld
munged the destructor and virtual table symbol names, and the result
is a patch to the egcs source to allow it to work with FreeBSD's
native ld.  Tim Liddelow's patch for 2.7.2 didn't work properly, the
problem seemed like name mangling got changed in the newer g++ branch.

The patch is against the 1008 snapshot, and it also works against the
1023, and I'll try to keep it current, though gcc/tlink.c seems fairly
stable, which is the only file affected by this patch.  It's
successfully linked a fairly large project (~10K lines), with template
functions and classes from the STL and some home-brewed templates
correctly getting instantiated.

Comments / questions / suggestions are welcome.

-Jay


--Multipart_Sun_Nov__2_22:09:10_1997-1
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="freebsd-egcs-repo-patch"
Content-Transfer-Encoding: 7bit

*** egcs-971008/gcc/tlink.c.orig	Thu Oct 30 21:23:35 1997
--- egcs-971008/gcc/tlink.c	Sun Nov  2 14:51:43 1997
***************
*** 555,560 ****
--- 555,598 ----
        if (! sym && ! end)
  	/* Try a mangled name in `quotes'.  */
  	{
+ #define USE_FREEBSD_LD 1
+ #ifdef USE_FREEBSD_LD
+ 	  char *psave = q + 1;
+ 	  p = (char *) index (q+1, '`');
+ 	  q = 0;
+ 
+ #define UND "Undefined symbol "
+ #define MUL "Definition of symbol "
+ 
+ 	  if (p)
+  	    {
+  	      *p = 0;
+  	      if (!strcmp (psave, UND) || !strcmp (psave, MUL)) 
+  		p++, q = (char *) index (p, '\'');
+  	    }
+ 
+ 	  if (q)
+ 	    {
+ 	      *q = 0;
+               if (strncmp(p,"vt::",4) == 0)
+               {
+                   q = p;
+                   *q++ = '_';
+                   *q++ = 'v';
+                   *q++ = 't';
+                   *q++ = '$';
+               }
+               else if (strncmp(p,"::_",3) == 0)
+               {
+                   q = p;
+                   *q++ = '_';
+                   *q++ = '$';
+               }
+ 	      else
+ 		  p++;
+ 	      sym = symbol_hash_lookup(p,false);
+ 	    }
+ #else
  	  demangled *dem = 0;
  	  p = (char *) index (q+1, '`');
  	  q = 0;
***************
*** 573,578 ****
--- 611,617 ----
  	    *q = 0, dem = demangled_hash_lookup (p, false);
  	  if (dem)
  	    sym = symbol_hash_lookup (dem->mangled, false);
+ #endif
  	}
  
        if (sym && sym->tweaked)

--Multipart_Sun_Nov__2_22:09:10_1997-1--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?rz8yb36smg9.fsf>