How to prevent export of characters from a statically linked library?

I created a shared library on linux x86. By creating it, I am statically linked in openssl. OpenSSL is only used internally, but I see that openssl characters have been exported. This causes problems for other libraries that need my AND openssl library, because the wrong character may be loaded at runtime. Is there a way to prevent all openssl characters from being exported while statically linking it to my shared library?

Thanks Mike

+4
source share
1 answer

Assuming you use gcc when you link your library, specify -fvisibility = hidden and in your library source, mark all the functions that you want to see as extern. I think this should work until openssl declares its own extern functions.

I think if openssl declared some extern characters, you can manually force the characters to hide using pragmas.

There are other options. Check out the gcc docs in the fvisibility section for a full explanation of what is available to you.

0
source

Source: https://habr.com/ru/post/1306295/


All Articles