Re: [GD-Linux] Determining address of C++ member function at run-time...
Brought to you by:
vexxed72
|
From: Ryan C. G. <ic...@cl...> - 2001-12-13 00:04:34
|
> Is dlopen/dlsym applicable here?
The problem with dlsym() is that the symbol would be mangled in a way that
varies between versions of gcc, so it's best for the dynamic linker to do
this work.
The odd thing is that, when statically linked, the code that Colin posted
( printf("%p", &(Foo::Bar)); ) works fine here.
You could always do something like this (which is uglier, but probably
safer, dlsym or otherwise):
extern "C"
{
void FooBarEntry(void)
{
Foo::Bar();
}
}
then do your lookup on FoorBarEntry instead of Foo::Bar. I dunno. I tend
to agree with Steve, there's probably a better way to do this without
resorting to this sort of thing.
> What I don't understand is *WHY* you need to do this. It seems
> like you must be doing something unbelievably **NASTY** and you ought
> to be looking for a better way to solve the problem than delving around
> in ikky machine details such as code addresses.
I'm rapidly coming to the belief that this should be the standard reply to
any questions on this list. :)
--ryan.
|