[ale] Programmatic loading & interrogation of so's

Joe Knapka whyknot at mindspring.com
Sat Aug 24 00:16:14 EDT 1996

Hello, ALE'rs.

I'm throwing this question out here in the hope that there's someone
who knows enough about dynamic loading under Linux to answer it. There's
a cool thing you can do with DLLs under OS/2 (and I presume Windog), and
I want to do it under Linux with shared libraries.

Here's the deal: there's a call you can make under OS/2 called something 

DLLhandle DosLoadModule(char* mod_name);

that loads the named DLL into the current process' address space, but 
_does not attempt to resolve any linker symbols_. Then you can make a 
system call

void* DosQueryDLLEntryPoint(DLLhandle dll,char* fn_name);

(or something like that; it's been a while since I did this), and it
will return to you the address of the named function within the DLL
you loaded. You can have multiple DLLs loaded in this manner with
the same function name defined in all of them, and you can decide at
runtime which libraries to load. Among other things, this makes
possible a truly beautiful implementation of the "Abstract Factory"
pattern from Gamma et al., where the DLLs are the factories and the
client code can configure itself dynamically, not only at startup but
even while the process is running.

I want to know (a) can this currently be done under Linux (I kind of
suspect not); (b) if so, how; and (c) if not, how much work would be
involved to add such capability? And to which forum would y'all suggest
I direct further inquiries?

Thanks for any pointers (or references :-)

-- Joe

More information about the Ale mailing list