Note that there are some explanatory texts on larger screens.

plurals
  1. POLinux, GNU GCC, ld, version scripts and the ELF binary format -- How does it work?
    primarykey
    data
    text
    <p>I'm trying to learn more about library versioning in Linux and how to put it all to work. Here's the context:</p> <p>-- I have two versions of a dynamic library which expose the same set of interfaces, say <code>libsome1.so</code> and <code>libsome2.so</code>.</p> <p>-- An application is linked against <code>libsome1.so</code>.</p> <p>-- This application uses <code>libdl.so</code> to dynamically load another module, say <code>libmagic.so</code>.</p> <p>-- Now <code>libmagic.so</code> is linked against <code>libsome2.so</code>. Obviously, without using linker scripts to hide symbols in <code>libmagic.so</code>, at run-time all calls to interfaces in <code>libsome2.so</code> are resolved to <code>libsome1.so</code>. This can be confirmed by checking the value returned by <code>libVersion()</code> against the value of the macro <code>LIB_VERSION</code>.</p> <p>-- So I try next to compile and link <code>libmagic.so</code> with a linker script which hides all symbols except 3 which are defined in <code>libmagic.so</code> and are exported by it. This works... Or at least <code>libVersion()</code> and <code>LIB_VERSION</code> values match (and it reports version 2 not 1).</p> <p>-- However, when some data structures are serialized to disk, I noticed some corruption. In the application's directory if I delete <code>libsome1.so</code> and create a soft link in its place to point to <code>libsome2.so</code>, everything works as expected and the same corruption does not happen.</p> <p>I can't help but think that this may be caused due to some conflict in the run-time linker's resolution of symbols. I've tried many things, like trying to link <code>libsome2.so</code> so that all symbols are alised to <code>symbol@@VER_2</code> (which I am still confused about because the command <code>nm -CD libsome2.so</code> still lists symbols as <code>symbol</code> and not <code>symbol@@VER_2</code>)... Nothing seems to work!!! Help!!!!!!</p> <p>Edit: I should have mentioned it earlier, but the app in question is Firefox, and <code>libsome1.so</code> is <code>libsqlite3.so</code> shipped with it. I don't quite have the option of recompiling them. Also, using version scripts to hide symbols seems to be the only solution right now. So what really happens when symbols are hidden? Do they become 'local' to the SO? Does rtld have no knowledge of their existence? What happens when an exported function refers to a hidden symbol?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload