How character binding works for shared libraries on Linux

When compiling a cpp program with g ++ -O0, I noticed that my binary does not contain the empty string character (basic_string): _S_empty_rep_storage When I compile the same program with -O2, I notice that the aforementioned character is actually contained inside the binary as follows ( using nm in the hopper):

00000000006029a0 V _ZNSs4_Rep20_S_empty_rep_storageE @@ GLIBCXX_3.4

My application uses several .so (dynamic libraries), and when my applications load, I notice that some of these .so files are linked as follows (I set LD_DEBUG = all and run my program):

 28596: binding file /home/bbazso/usr/local/lib/mydynamiclib.so [0] to /usr/lib64/libstdc++.so.6 [0]: normal symbol `_ZNSs4_Rep20_S_empty_rep_storageE' [GLIBCXX_3.4]
 28596: binding file /home/bbazso/usr/local/lib/mydynamiclib.so [0] to /home/bbazso/workspace/mytestapplication [0]: normal symbol `_ZNSs4_Rep20_S_empty_rep_storageE' [GLIBCXX_3.4]
 28596: binding file /home/bbazso/workspace/mytestapplication [0] to /usr/lib64/libstdc++.so.6 [0]: normal symbol `_ZNSs4_Rep20_S_empty_rep_storageE' [GLIBCXX_3.4]**

But I also noticed that one of my .so links only as follows:

  28087:    binding file /home/bbazso/usr/local/lib/anotherdynamiclib.so [0] to /usr/lib64/libstdc++.so.6 [0]: normal symbol `_ZNSs4_Rep20_S_empty_rep_storageE' [GLIBCXX_3.4]

but it never binds to binary (mytestapplication) as shown above for mydynamiclib.so.

So, I was wondering what that really means? Does this mean that anotherdynamiclib.so will use a different character for the empty string higher than the rest of the application? I suppose I'm really asking how character binding works in the context of the above example?

Thank!

+3
source share
2 answers

I'm afraid I don't fully understand your question, but you can find the answer in an Ulrich Drepper article titled How to Write Shared Libraries . This is the best I know about characters with elf binaries in Linux.

+1

. , , .

,    , "". , , , "". @@GLIBCXX_3.4. GLIBCXX (, libstd++).

nm ST_BIND ( st_info El32_Sym/Elf64_Sym). , , . readelf -s YOURBINNAME .

0

Source: https://habr.com/ru/post/1734272/


All Articles