From owner-freebsd-hackers Mon Aug 18 23:50:46 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id XAA15988 for hackers-outgoing; Mon, 18 Aug 1997 23:50:46 -0700 (PDT) Received: from firewallint.avl.co.at (avlgate.avl.co.at [157.247.254.2]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id XAA15978 for ; Mon, 18 Aug 1997 23:50:38 -0700 (PDT) Received: from umes01.avl.co.at (umes01.avl.co.at [157.247.2.25]) by firewallint.avl.co.at (8.8.5/8.8.5) with ESMTP id IAA10159 for ; Tue, 19 Aug 1997 08:50:20 +0200 (MDT) Received: from nmes74 (nmes74.avl.co.at [157.247.8.233]) by umes01.avl.co.at (8.8.5/8.8.5) with SMTP id IAA10975 for ; Tue, 19 Aug 1997 08:50:58 +0200 (MET DST) Date: Tue, 19 Aug 1997 08:52:40 From: Hermann Schinagl To: hackers@freebsd.org Subject: Re: Please Help Me Understand dlopen()] Message-Id: <19970819085282.NTM1204@umes01.avl.co.at> X-Mailer: NTXMail B.01.50.340 (Intel 32-bit) (Apr 23 1997 16:40:57 0007-150-BTT00000027) MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by hub.freebsd.org id XAA15983 Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >I think the fix should assume that the application most likely wants >to look up a normal C symbol. So it should do something like this: > > /* > * First try: look for a normal C symbol like (in assembly > * language) "_foo". > */ > if (sym starts with "_") /* Assume caller already added "_" */ > trysym = sym; > else /* Add "_" for caller */ > trysym = concat("_", sym); /* Not C, but you get the idea */ > > if (lookup(trysym)) > return success; > > /* > * Second try: look for a strange C symbol like (in assembly > * language) "__foo", or an assembly language symbol "foo" with no > * underscore at all. > */ > if (sym starts with "_") /* Assume C symbol really starts with "_" */ > trysym = concat("_", sym); > else /* Assume caller wants assembly symbol */ > trysym = sym; > > if (lookup(trysym)) > return success; > > /* > * Give up. > */ > return failure; You forgot that the symbols, which are exported by the lib are totally different, if you rename a .c file to .cpp and compile it again. ==> C++ exported symbols Well, it is easy to add '_' before the symbol, but the function-arguments of a C++ exported function are append encoded to the symbolname. eg.: '__func027_dfiv' So writing a wrapper is not that straight forward as mentioned above. You should also think of the C++ exporting mechanism. Ciao Hermann Regards, Hermann Schinagl -------------------------------------------------------------------- Dipl.-Ing. Hermann Schinagl AVL List GmbH Kleiststrasse 48 Email : schinagl@avl.co.at A-8020 Graz Phone : ++43 316 987 324 PGP : http://www.pgp.net/pgp Power and ignorance is a disgusting cocktail.