dlopen uses function from another library - why?

dlopen uses function from another library - why?

Post by Ted Su » Sun, 04 Nov 2001 00:47:05



Hi,

I use dlopen to setup some function pointers.  Let's say I call a
function a() from the dynamic library opened via dlopen.  Function a()
calls b() in turn.
b() is in the dynamic library but is also in another library I link
(statically) to.  It turns out that the b() function being executed is
the
later.  How can I force function a() to call b() that's in it's own
dynamic library?

Thanks,

Ted

 
 
 

dlopen uses function from another library - why?

Post by Paul Pluzhniko » Sun, 04 Nov 2001 01:03:55



Quote:> Hi,

> I use dlopen to setup some function pointers.  Let's say I call a
> function a() from the dynamic library opened via dlopen.  Function a()
> calls b() in turn.
> b() is in the dynamic library but is also in another library I link
> (statically) to.  It turns out that the b() function being executed is
> the later.

That is how all UNIX shared libraries (except AIX) are designed to work:
the first 'b()' defined (in this case by the main executable) is the
one that runtime loader will use.

Quote:> How can I force function a() to call b() that's in it's own
> dynamic library?

The answer depends on the system.
On Solaris and Linux, man ld and see what -Bsymbolic does

 
 
 

dlopen uses function from another library - why?

Post by Casper H.S. Dik - Network Security Engine » Sun, 04 Nov 2001 01:18:17


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>The answer depends on the system.
>On Solaris and Linux, man ld and see what -Bsymbolic does

On Solaris, you can also hide the functions in the main application
by specifying a linker map.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.