Irbis
Irbis

Reputation: 1491

Linux and shared libraries, linking vs dlopen - symbol visibility

I work on Linux. When my application links to the shared library (which doesn't hide symbols) all symbols from that library are visible. A shared library can also be loaded at runtime using dlopen. Is it possible to control symbols visiblity using dlopen mode parameter or I always have to get desire symbol using dlsym ?

Upvotes: 0

Views: 967

Answers (1)

Employed Russian
Employed Russian

Reputation: 213375

Your question is exceedingly unclear.

If you dlopen the library, then about the only way to get to any of its symbols is via dlsym.

However, if you dlopen a library with RTLD_GLOBAL, then its symbols become available for subsequently loaded libraries without using dlsym.

For example, if libfoo.so defines symbol foo, and if you dlopen("libfoo.so", RTLD_GLOBAL|...); and later dlopen("libbar.so", ...) which uses foo, that would work -- libbar.so will be able to use foo from libfoo.so without doing any dlsym calls.

Upvotes: 2

Related Questions