| Paul Pluzhnikov 2006-07-20, 1:47 am |
| gazelle@xmission.xmission.com (Kenny McCormack) writes:
> Is it possible to do the equivalent of dlopen with an executable (i.e.,
> not shared lib) ?
On Linux, "dlopen(NULL, ...)" returns you the handle to the main
executable. This handle works fine for subsequent dlsym()s,
provided the exe exports the function you need in its dynamic symbol
table ("nm -D a.out").
> ISTR, that it was
> somehow possible to do the same thing (i.e., execute routines stored
> within) a regular executable as well.
Calling routines in the main executable from a DSO is easy, provided
that you know routine name at DSO compile time, and that the routine
is dynamically exported from the exe.
If the exe loads foo.so (as a plugin) and defines bar() as
dynamically exported symbol, then put this into foo.so:
int foo() {
return bar();
}
and foo.so`foo() will happily call a.out`bar()
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
|