This is the mail archive of the
mailing list for the binutils project.
Is it possible to link solib privately?
- From: Stas Sergeev <stsp at list dot ru>
- To: binutils at sourceware dot org
- Date: Mon, 15 Sep 2014 12:30:43 +0400
- Subject: Is it possible to link solib privately?
- Authentication-results: sourceware.org; auth=none
My problem is as follows.
Say, I have 2 libs: foo (libfoo.so) and bar (libbar.so).
foo uses the API of bar, and is therefore linked with -lbar.
There is also an app that uses the API of both foo and
bar, and is therefore linked with -lfoo -lbar.
Now lets assume that bar is coded in some poor way and
its API depends on a global state a lot. When the app
uses it, it works fine. When foo uses it, it works fine as well.
But when they use it together (even without threads, sequentially),
its global state gets corrupted and the API stops working.
My question is: is it possible to link bar to foo somehow
privately, so that it uses the private data sections, independent
of those used when the app calls the bar API directly?
I know how to do that if libbar is a static lib, but it is not static,
and also it would be nice to have the code sections still shared.
Is there some magic linker flag to achieve what I want?
Or any other work-arounds I can consider?