Bug 11350 - Broken versioned symbols in the output for the relocatable objects
Summary: Broken versioned symbols in the output for the relocatable objects
Status: ASSIGNED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-04 23:43 UTC by Viktor Kutuzov
Modified: 2016-03-27 15:18 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Last reconfirmed:


Attachments
Readelf output for the source object (444 bytes, text/plain)
2010-03-04 23:44 UTC, Viktor Kutuzov
Details
Readelf output for the result object (386 bytes, text/plain)
2010-03-04 23:45 UTC, Viktor Kutuzov
Details
The source object (4.42 KB, application/octet-stream)
2010-03-04 23:45 UTC, Viktor Kutuzov
Details
The rsult obejct (4.37 KB, application/octet-stream)
2010-03-04 23:46 UTC, Viktor Kutuzov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Viktor Kutuzov 2010-03-04 23:43:10 UTC
When linking a relocatable object, where any input object has the defined global
versioned symbols, gold cuts the symbol version for the symbols in the output
symbol table. It means, that kind of symbols lose the version information in the
output object; also, if the input object has two versions of one symbol --
versioned and non-versioned -- the output object will contain two symbols with
identical names (duplicate).

There is some example for GNU gold (GNU Binutils 2.20.51.20100304) 1.9

This is a part of readelf output for the input object (readelf -sW divdi3.os),
which shows the versioned and non-versioned symbols for __divdi3:

Symbol table '.symtab' contains 34 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
...
    20: 000005dc   120 FUNC    GLOBAL DEFAULT    1 __divdi3
...
    30: 000005dc   120 FUNC    GLOBAL DEFAULT    1 __divdi3@GLIBC_2.4
...

Link the input object as relocatable with the following command:

ld -r -o divdi3.out divdi3.os


This is a part of readelf output for the result object (readelf -sW divdi3.out),
which shows the symbol duplicates for __divdi3:

Symbol table '.symtab' contains 27 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
...
    13: 000005dc   120 FUNC    GLOBAL DEFAULT    1 __divdi3
...
    24: 000005dc   120 FUNC    GLOBAL DEFAULT    1 __divdi3
...

(I will attach the complete readelf outputs to the bug report)

So, as far as I understood, it happens because of two linked problems: the
Symbol_table::sized_write_symbol method always looks for the non-versioned
version of symbol in the symbol names string pool; and the symbol names string
pool never gets a string representation for that kind of versioned symbols (i.e.
the strings like "name@ver").
Comment 1 Viktor Kutuzov 2010-03-04 23:44:20 UTC
Created attachment 4646 [details]
Readelf output for the source object
Comment 2 Viktor Kutuzov 2010-03-04 23:45:23 UTC
Created attachment 4647 [details]
Readelf output for the result object
Comment 3 Viktor Kutuzov 2010-03-04 23:45:52 UTC
Created attachment 4648 [details]
The source object
Comment 4 Viktor Kutuzov 2010-03-04 23:46:15 UTC
Created attachment 4649 [details]
The rsult obejct