Symver attribute

Jonathan Wakely jwakely@redhat.com
Mon Dec 2 11:07:00 GMT 2019


On 30/11/19 22:13 +0100, Jan Hubicka wrote:
>Hi,
>this is patch incorporating (I hope) all the suggestions and corrections
>which I applied.  I will work incremnetaly on supporting the name@@@node
>semantics which is bit different from @ and @@ one by actually removing
>the original symbol.  Here I need to change assembler name of the symbol
>itself but then I still need an alternative assembler name for the local
>use. This is bit like weakref rewriting but not quite and it seems it is
>better to do that incrementally.
>
>It would be great to convert libstdc++ to the new infrastructure so it
>becomes LTO safe and gives some real world testing to this
>infrastructure.  I tried that but found it is bit non-trivial since
>currently way we need to attach the attribute to definition itself,
>while current .symver output is done in separate C++ files.

I will add it to my TODO list.


>Index: doc/extend.texi
>===================================================================
>--- doc/extend.texi	(revision 278877)
>+++ doc/extend.texi	(working copy)
>@@ -3711,6 +3711,41 @@ Function Attributes}, @ref{PowerPC Funct
> @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
> for details.
>
>+@item symver ("@var{name2}@@@var{nodename}")
>+On ELF targets this attribute creates a symbol version.  The @var{name2} part
>+of the parameter is the actual name of the symbol by which it will be
>+externally referenced.  The @code{nodename} portion should be the name of a
>+node specified in the version script supplied to the linker when building a
>+shared library.  Versioned symbol must be defined and must be exported with

I think this should be either "A versioned symbol" or "Versioned
symbols".

>+default visibility.
>+
>+@smallexample
>+__attribute__ ((__symver__ ("foo@@VERS_1"))) int
>+foo_v1 (void)
>+@{
>+@}
>+@end smallexample
>+
>+Will produce a @code{.symver foo_v1, foo@@VERS_1} directive in the assembler
>+output.
>+
>+It's an error to define multiple version of a given symbol.  In such case

"In such cases"

>+an alias can be used.
>+
>+@smallexample
>+__attribute__ ((__symver__ ("foo@@VERS_2")))
>+__attribute__ ((alias ("foo_v1")))
>+int symver_foo_v1 (void);
>+@end smallexample
>+
>+This example creates an alias of @code{foo_v1} with symbol name
>+@code{symver_foo_v1} which will be version @code{VERS_2} of @code{foo}.
>+
>+Finally if the parameter is @code{"@var{name2}@@@@@var{nodename}"} then in
>+addition to creating a symbol version (as if
>+@code{"@var{name2}@@@var{nodename}"} was used) the version will be also used

s/was used/had been used/

s/will be also used/will also be used/



More information about the Gcc-patches mailing list