public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* name mangle function?
@ 2001-06-11  6:56 Steve Boswell
  2001-06-12 16:52 ` Alexandre Oliva
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Boswell @ 2001-06-11  6:56 UTC (permalink / raw)
  To: gcc

Hello,

I would like to use dlopen/dlsym to build a middleware layer on top
of a shared object library linked from C++ source.  The most convenient
thing I can think of (other suggestions appreciated, of course),
would be to have access to a function that, given a class/method in the
C++ source, will give me a null terminated string representing the
mangled symbol name as produced by the compiler.
Is there such a function in gcc?  

Apologies if this is documented elsewhere.  I've searched around for a
few hours, didn't spot it.

Thanks,
Steve

-- 
===================================
Steven B. Boswell, Ph.D.
BBN Technologies
10 Moulton Street
Cambridge, MA 02138

617-873-5284 (voice and voicemail)
617-873-2794 (fax)

sboswell@bbn.com
===================================

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: name mangle function?
  2001-06-11  6:56 name mangle function? Steve Boswell
@ 2001-06-12 16:52 ` Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2001-06-12 16:52 UTC (permalink / raw)
  To: Steve Boswell; +Cc: gcc

On Jun 11, 2001, Steve Boswell <sboswell@bbn.com> wrote:

> would be to have access to a function that, given a class/method in the
> C++ source, will give me a null terminated string representing the
> mangled symbol name as produced by the compiler.
> Is there such a function in gcc?  

Nope.  Think namespaces, nested classes, argument types, etc, and
you'll see it's not that simple.  Besides, dlsym would only be useful
for static methods (you can't use the pointer dlsym would return to
call a non-static method).

In general, the advice I give to people who want to dlopen C++
libraries is to define a library interface with extern "C" functions
(or static methods), or with global variables of object type
containing pointers to methods.  Neither extern "C" functions nor
global variables are subject to name mangling.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-06-12 16:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-11  6:56 name mangle function? Steve Boswell
2001-06-12 16:52 ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).