dynamically loading shared libraries

dynamically loading shared libraries

Post by Greg Thompso » Sat, 27 Jul 1996 04:00:00



  MC> I am porting some software to unix (including AIX 4.x), but I
  MC> don't have access to an AIX 4.x machine yet, and was wondering
  MC> if anyone could tell me what the AIX equivalent of HP-UX's
  MC> shl_load() and Solaris' dlopen() series of commands. Is there
  MC> any way to get a man-page like description of these functions so
  MC> that I can come up with a design that has some hope of working
  MC> on as many unix variants as possible?

if you're porting to AIX 4.2, then the dlfcn stuff is in there, just
like solaris.  if you're porting to AIX 4.1, you should get the free
package from ibm called "Shared Library Hookable Symbols/6000", aka
PRPQ 91153, which implements the dlfcn stuff.

as an alternative, you can load up an object via load(), and then use
loadquery() to find out where the symbol table is in memory, and then
you can search for a given symbol by yourself.  it's a bit more of a
pain than just getting the above PRPQ and using the dlfcn library.

there's also a partial dlfcn emulation lib written by Jens-Uwe Mager.
you can find it at <URL:ftp://anubis.han.de/pub/aix/dlfcn.shar>.
after evaluating it, i chose not to use it since it doesn't handle
dlopen(NULL), and it searches for all symbols in the object on the
dlopen, which isn't what i wanted.  i went with using load() and
loadquery() since they'll work on AIX 3.2.5 and 4.x, both of which i
needed to support.
--
                -greg       loaded up on dynamite. hey brother can you
                            spare a light. i'm going to scrape the sky
                                  tonight and shake down all the stars
                                                      -poster children

 
 
 

dynamically loading shared libraries

Post by Mark Cudwor » Sat, 27 Jul 1996 04:00:00


I am porting some software to unix (including AIX 4.x), but I don't have
access to an AIX 4.x machine yet, and was wondering if anyone could tell
me what the AIX equivalent of HP-UX's shl_load() and Solaris' dlopen()
series of commands. Is there any way to get a man-page like description
of these functions so that I can come up with a design that has some hope
of working on as many unix variants as possible?

Any help would be greatly appreciated.

--

--------------------------------------------------------
        Mark Cudworth

--------------------------------------------------------

 
 
 

dynamically loading shared libraries

Post by Jens-Uwe Mag » Sat, 27 Jul 1996 04:00:00



> I am porting some software to unix (including AIX 4.x), but I don't have
> access to an AIX 4.x machine yet, and was wondering if anyone could tell
> me what the AIX equivalent of HP-UX's shl_load() and Solaris' dlopen()
> series of commands. Is there any way to get a man-page like description
> of these functions so that I can come up with a design that has some hope
> of working on as many unix variants as possible?

I think the dlopen() approach is the most widely accepted way in the Unix
community to perform dynamic loading. For AIX you can ask either IBM for a
dlopen style library or you can download my dlopen() glue library from
<ftp://anubis.han.de/pub/aix/dlfcn.shar>.
______________________________________________________________________________


Brahmsstr. 3                    Tel.: +49 511 660238
 
 
 

dynamically loading shared libraries

Post by gues » Sat, 27 Jul 1996 04:00:00




:I am porting some software to unix (including AIX 4.x), but I don't have
:access to an AIX 4.x machine yet, and was wondering if anyone could tell
:me what the AIX equivalent of HP-UX's shl_load() and Solaris' dlopen()
:series of commands. Is there any way to get a man-page like description

AIX 4.2 supports svr4ish dlopen(), ... For earily versions to 3.x, you can
either order it from IBM or use load()/unload()/... (or loadAndInit()/
terminateAndUnload() for invoking the c++ constructors/destructors) and
easily build those dlopen()/... functioins.

Also, on HP-UX, if you want the constructors/destructors be invoked,
you need use cxxshl_load/cxxshl_unload come with HP CC compiler(defined
in libC.sl.x library).

:of these functions so that I can come up with a design that has some hope
:of working on as many unix variants as possible?

As dlopen()/... offers minimum functionilities compare to native HP and
AIX functions(means you can easily mapped them to it) and available on
almost all unix platforms(except for earily non-ELF (i.e. native a.out)
and some COFF systems like SCO ODT 3.x, ultrix, A/UX, ...), you can safely
based your design on dlopen by assuming it is available everywhere.

:
:Any help would be greatly appreciated.
:
:--
:
:--------------------------------------------------------
:        Mark Cudworth

:--------------------------------------------------------

 
 
 

1. Dynamically Loaded Shared Libraries and dbx

SUMMARY:

Program and libraries have proper common resolution, but dbx doesn't.

PROGRAM ARCHITECTURE:

Mixed C & FORTRAN main executable exports a common block.
FORTRAN shared library imports the common block.
Main executable dynamically loads shared library (load & loadbind),
then invokes a subroutine in the shared library (exported, of course).
The subroutine references the exported common in the process of
performing it's function.

PROBLEM:

This program works fine!  Even in dbx.  But dbx doesn't work fine.

While stepping through a subroutine in the library, I attempt to print
the value of a common variable exported from the main executable, and
dbx gives a value which I know not to be true, and which would break
the program if it were.

Here's a partial transcript (with the names changed for clarity) to
show you what I mean.  The main characters are:
    GLOBVAR, a common variable which is exported from the main executable
    LOCVAR, a local variable (in the subroutine)

-----Begin-Debugging-Transcript------------------------
stopped in file1 at line 96 in file "file1.f"
   96         LOCVAR = GLOBVAR
(dbx) p LOCVAR,GLOBVAR
0 -1
(dbx) n
stopped in file1 at line 97 in file "file1.f"
   97         IPTNDI = 0
(dbx) p LOCVAR,GLOBVAR
51195 -1
(dbx) whatis LOCVAR
 integer*4 locvar
(dbx) whatis GLOBVAR
 integer*4 globvar
-----End-Debugging-Transcript--------------------------

DISCUSSION:

I believe that the debugger is looking at a local copy of the common,
rather than the exported copy that the actual code uses.  What I'm
looking for is a way to tell dbx to look at the same common the
program uses.

Since this is a large project, with more than 50 shared libraries,
hundreds of common blocks, thousands of source files, and half a dozen
developers, I'm looking for a general debugging solution which doesn't
require code changes.


I'll summarize to the net.  Thanks.

--
The above statements are not the opinions or policies of SPSS Inc.
The above statements may not be the opinions of Brent Lambert.
The first disclaimer is a policy of SPSS Inc.
Subsequent disclaimers are probably the opinion of Brent Lambert.

2. lpd unresponsive across network -- why?

3. Unresolved references in dynamically loaded shared library (SunOS 4.1.3)

4. redhat - probe ide

5. Controlling exports in Dynamically loaded shared libraries

6. Apache/Performance/Compilation/Linux

7. Calling Linux-PAM from a dynamically loaded shared library

8. Where did my space go?

9. Is there a way to load share library dynamically in C on Unix platform?

10. Dynamically Loading a Shared Library on HP-UX

11. Shared library loading shared library.

12. error in loading shared libraries: libXmu.so.6: cannot open shared object