From owner-freebsd-questions Sun Nov 2 19:09:31 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id TAA00217 for questions-outgoing; Sun, 2 Nov 1997 19:09:31 -0800 (PST) (envelope-from owner-freebsd-questions) Received: from harmony.williams.edu (harmony.williams.edu [137.165.4.25]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id TAA00207 for ; Sun, 2 Nov 1997 19:09:27 -0800 (PST) (envelope-from sachs@bull.cs.williams.edu) Received: from cs.williams.edu (bull.cs.williams.edu) by williams.edu (PMDF V5.1-10 #24595) with SMTP id <0EJ100ATHVG0CP@williams.edu> for freebsd-questions@freebsd.org; Sun, 2 Nov 1997 22:09:36 -0500 (EST) Received: from bulldozer.williams.edu by cs.williams.edu (SMI-8.6/SMI-SVR4) id WAA11863; Sun, 02 Nov 1997 22:09:11 -0500 Received: by bulldozer.williams.edu (SMI-8.6/SMI-SVR4) id WAA10023; Sun, 02 Nov 1997 22:09:11 -0500 Date: Sun, 02 Nov 1997 22:09:10 -0500 From: Jay Sachs Subject: patch for egcs -frepo to work with FreeBSD ld To: egcs-bugs@cygnus.com, freebsd-questions@freebsd.org Message-id: MIME-version: 1.0 (generated by tm-edit 7.106) X-Mailer: Gnus v5.4.67/XEmacs 19.15 Content-type: multipart/mixed; boundary="Multipart_Sun_Nov__2_22:09:10_1997-1" Content-transfer-encoding: 7bit X-Face: 6!-I&o^[[HP+0~O~}d2Zf@Pbof:|>j5^*W$QOR"&)JYcHT.@-"AhAXLg3vioV79Ri3JMp/a e3QD@Z$1Ot@'j1/A Lines: 87 Sender: owner-freebsd-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk --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--