Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Aug 1997 08:52:40
From:      Hermann Schinagl <schinagl@avl.co.at>
To:        hackers@freebsd.org
Subject:   Re: Please Help Me Understand dlopen()]
Message-ID:  <19970819085282.NTM1204@umes01.avl.co.at>

next in thread | raw e-mail | index | archive | help
>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.





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