This a bit difficult to understand but I'm doing my best.
On Red Hat 6.4 with gcc 4.4.6 & ld 2.20.51,
I am linking into a binary executable PROGRAM code from one shared library (.so) and a static library (.a).
The shared library exposes an API invoked directly by PROGRAM. The implementation of this shared library is compiled & linked against a static library static lib1.
The static library also exposes its own API which is invoked directly by PROGRAM. And some of its implementation is based on a subset of the static lib1's files that were copied directly into it.
None of the APIs (of either library) actually expose a data type or a function implemented by static lib1.
Because the code was copied the symbols are identical.
During runtime I see this behaviour:
- If the order of libraries to the linker is shared library, static library, then calls to the shared library API and calls to the static library* API will both use the implementation in the **static lib1.
- If the order of libraries to the linker is static library, shared library, then calls to the shared library API and calls to the static library API will both use the implementation in the static library 1 - code from lib1 modified.
How do I get all calls to the static library API to run the implementation in code from lib 1 modified and those in the shared library API run the implementation in static lib1?