LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-05-2012, 05:06 AM   #1
sindy07
LQ Newbie
 
Registered: Mar 2012
Posts: 5

Rep: Reputation: Disabled
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.
 
Old 10-07-2012, 01:55 AM   #2
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 669

Rep: Reputation: 134Reputation: 134
Quote:
Originally Posted by sindy07 View Post
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'ld' is not finding symbols in a static library RileyTheWiley Programming 1 04-20-2012 10:11 AM
'nm' lists all symbols - including static library symbols painulyarun Programming 4 04-06-2010 05:04 AM
Debugger selectively not using symbols in library with symbols Millenniumman Programming 5 03-25-2007 10:44 AM
Debugger selectively not using symbols in library with symbols Millenniumman Programming 1 03-03-2007 08:46 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration