.symver
Use the .symver
directive to bind symbols to specific version nodes
within a source file. This is only supported on ELF platforms, and is
typically used when assembling files to be linked into a shared library.
There are cases where it may make sense to use this in objects to be bound
into an application itself so as to override a versioned symbol from a
shared library.
For ELF targets, the .symver
directive can be used like this:
.symver name, name2@nodename[ ,visibility]
If the original symbol name is defined within the file
being assembled, the .symver
directive effectively creates a symbol
alias with the name name2@nodename, and in fact the main reason that we
just don’t try and create a regular alias is that the @ character isn’t
permitted in symbol names. The name2 part of the name is the actual name
of the symbol by which it will be externally referenced. The name name
itself is merely a name of convenience that is used so that it is possible to
have definitions for multiple versions of a function within a single source
file, and so that the compiler can unambiguously know which version of a
function is being mentioned. The nodename portion of the alias should be
the name of a node specified in the version script supplied to the linker when
building a shared library. If you are attempting to override a versioned
symbol from a shared library, then nodename should correspond to the
nodename of the symbol you are trying to override. The optional argument
visibility updates the visibility of the original symbol. The valid
visibilities are local
, hidden
, and remove
. The
local
visibility makes the original symbol a local symbol
(see .local names
). The hidden
visibility sets the visibility of the
original symbol to hidden
(see .hidden names
). The remove
visibility removes the original symbol from the symbol table. If visibility
isn’t specified, the original symbol is unchanged.
If the symbol name is not defined within the file being assembled, all references to name will be changed to name2@nodename. If no reference to name is made, name2@nodename will be removed from the symbol table.
Another usage of the .symver
directive is:
.symver name, name2@@nodename
In this case, the symbol name must exist and be defined within the file being assembled. It is similar to name2@nodename. The difference is name2@@nodename will also be used to resolve references to name2 by the linker.
The third usage of the .symver
directive is:
.symver name, name2@@@nodename
When name is not defined within the file being assembled, it is treated as name2@nodename. When name is defined within the file being assembled, the symbol name, name, will be changed to name2@@nodename.