Yorkwar
Yorkwar

Reputation: 1274

how to tell the run-time loader not to run the constructor function when dlopen a shared library

From the manual of dlopen, I see

" Instead, libraries should export routines using the attribute((constructor)) and attribute((destructor)) function attributes. See the gcc info pages for information on these. Constructor routines are executed before dlopen() returns, and destructor routines are executed before dlclose() returns. "

I do not want the constructor in a specific shared library to run automatically, while the ones in other shared libraries are not affected. Is there any way to achieve that?

Actually, I'm using dlopen, dlsym, dladdr to find the exact path of some shared library.

Upvotes: 2

Views: 472

Answers (1)

Employed Russian
Employed Russian

Reputation: 213879

I do not want the constructor in a specific shared library to run automatically

Too bad: the library author decided that his library can't be used safely unless the constructors are run, and he has more say than you do.

Actually, I'm using dlopen, dlsym, dladdr to find the exact path of some shared library.

Are you saying that the only reason you dlopen that library is just so that you can find the absolute path to it?

If so, why do you care about the absolute path in the first place?

Upvotes: 0

Related Questions