LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Export symbols of library though same symbol is exposed already using diff library (http://www.linuxquestions.org/questions/linux-software-2/export-symbols-of-library-though-same-symbol-is-exposed-already-using-diff-library-4175430640/)

sindy07 10-05-2012 05:06 AM

Export symbols of library though same symbol is exposed already using diff library
 
Hi,

We have a scenario where Library A and Library B has many duplicate function definition, because of which finding difficulties in using exposed symbols.

In this case A and B are independent libraries and loaded separately. So in a system if library A is loaded first then always symbols of A is used. Later at runtime if library B is loaded, it's functions are not getting exposed, library B starts using the functions of library A. Because of this static variable of library A is getting updated. Later if some application tries to use library A directly because of static value change, unexpected behavior is seen.

So here our question is, is it possible to tell library B to use its function even if library A's functions are already exposed.

Note we can't use export or inline as almost all the functions of library A and library B are same.

Can this be achieved using Makefile change?

Thanks,
Sindya K.

Valery Reznic 10-07-2012 01:55 AM

Quote:

Originally Posted by sindy07 (Post 4797876)
Hi,

We have a scenario where Library A and Library B has many duplicate function definition, because of which finding difficulties in using exposed symbols.

In this case A and B are independent libraries and loaded separately. So in a system if library A is loaded first then always symbols of A is used. Later at runtime if library B is loaded, it's functions are not getting exposed, library B starts using the functions of library A. Because of this static variable of library A is getting updated. Later if some application tries to use library A directly because of static value change, unexpected behavior is seen.

So here our question is, is it possible to tell library B to use its function even if library A's functions are already exposed.

Note we can't use export or inline as almost all the functions of library A and library B are same.

Can this be achieved using Makefile change?

Thanks,
Sindya K.


When you build library B you can pass -Bsymbolic to ld
from ld man page
Code:

      -Bsymbolic
          When creating a shared library, bind references to  global  symbols
          to  the definition within the shared library, if any.  Normally, it
          is possible for a program linked against a shared library to        over-
          ride the definition within the shared library.  This option is only
          meaningful on ELF platforms which support shared libraries.

Parameters to ld can be passed using -Xlinker gcc's switch.

But the question why you should mix such similar libraries?


All times are GMT -5. The time now is 04:44 AM.