c++linuxlinkershared-librariesname-mangling

What does the '@@' symbol mean in the output of nm command?


I'm looking at the output of 'nm' command for a shared lib in Linux. I see this

U stderr@@GLIBC_2.0

Does that mean stderr is hardlinked the glibc2.0? The reason I'm asking this we have a set of libraries (let's say a1.so, a2.so, ...) that are built against one of the different versions of our exported libraries (let's say ex.so.1, ex.so.2). The exported libraries all export a function, say foo. When the a*.so libraries are loaded, they somehow magically patch the appropriate functions inside the libraries they were built against. I see the output of nm for different libraries like below.

nm a1.so | grep foo
U foo@@ex.1

nm a2.so | grep foo
U foo@@ex.2

What role does the '@@' play here? I couldn't find any documentation about the '@@'. Any references would be helpful.


Solution

  • The @ allows specifying a version for a symbol. When multiple definitions of a symbol exist, they'd have different versions. To indicate the default version, @@ is used. The default version is chosen if no explicit version is specified.

    More details can be found in the binutils VERSION documentation (search for "@@").