3

When using readelf on executables, I get a number in parenthesis after some symbols names. For instance:

Num:    Value          Size Type    Bind   Vis      Ndx Name
 49: 00000000002052a0     8 OBJECT  GLOBAL DEFAULT   27 stderr@GLIBC_2.2.5 (3)

There is a (3) after the symbol name for stderr in that case. What does this means ?

deadalnix
  • 2,255
  • 18
  • 24
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Oct 14 '17 at 19:31
  • @jww you all due respect you are plain wrong. – deadalnix Oct 15 '17 at 20:07
  • As phrased, this question has nothing to do with programming and development. If you want help with commands, you should ask at [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/). – jww Oct 15 '17 at 22:18

1 Answers1

5

It is version symbol, where @GLIBC_2.2.5 comes from.

The number references to the entry of .gnu.version_r section

ELF symbol versioning is a GNU extension to ELF. When resolving a symbol with version, if the target symbol also has version, the version must match, or the symbol can be resolved.

To maintain compatibility the version is not stored inside .dynsym section. Instead it is stored inside .gnu.version section.

.gnu.version has exactly same number of entries as .dynsym section, each entry store the corresponding symbol version (with 0 means no version requirement).

version is a string, and .gnu.version stores a index which references to the .gnu.version_r table. The number follow the symbol name is the index.

Following describes how to find the version string of a symbol:

  1. assume resolving T symbol
  2. the symbol is located at n-th entryof .dynsym section
  3. look n-th entry of .gnu.version section, get the version number m
  4. traverse .gnu.version_r section, find entry with version number m
  5. the entry in .gnu.version_r section contains the corresponding version string (an index reference to .dynstr section)

The number following symbol name is the number m

Zang MingJie
  • 5,164
  • 1
  • 14
  • 27
  • I'm not sure what that means. Do you have some documentation i can read about that ? All i find is http://refspecs.linuxbase.org/LSB_2.0.1/LSB-PDA/LSB-PDA/specialsections.html but it's rather scarce in information. – deadalnix Oct 14 '17 at 12:25
  • Thanks for updating the answer with clarification about gnu.version. That's very helpful. – deadalnix Oct 14 '17 at 14:32