Hi Jan,
> thanks for feedback. Here is updated patch that incorporates Martin's
> changes, formatting corrections and makes symvers of aliases work.
just a few nits.
> Index: doc/extend.texi
> ===================================================================
> --- doc/extend.texi (revision 278293)
> +++ doc/extend.texi (working copy)
> @@ -3640,6 +3640,34 @@ 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 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 of the alias should be the name of a
Better be consistent and use @var{} in both cases.
> +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
> +default visibility.
> +
> +@smallexample
> +__attribute__ ((__symver__ ("foo@@VERS_1"))) int
> +foo_v1 (void)
> +@{
> +@}
> +@end smallexample
> +
> +Will produce @code{.symver foo_v1, foo@@VERS_1} directive in the assembler
> +output. It is not allowed to make multiple versions out of one symbol,
> however
> +versioned symbol may also be an alias.
> +
> +@smallexample
> +__attribute__ ((__symver__ ("foo@VERS_2")))
this broke bootstrap:
/vol/gcc/src/hg/trunk/local/gcc/doc/extend.texi:3663: unknown command `VERS'
make[3]: *** [Makefile:3273: doc/gcc.info] Error 1
You need to be careful to properly quote @'s in texinfo.
> +__attribute__ ((alias ("foo_v1")))
> +int symver_foo_v1 (void);
> +@end smallexample
> +
> +This example creates alias an of @code{foo_v1} with symbol name
> +@code{symver_foo_v1} which will be version @code{VERS_2} of @code{foo}.
> +
> @item target_clones (@var{options})
> @cindex @code{target_clones} function attribute
> The @code{target_clones} attribute is used to specify that a function
Martin already commented on the doc snippet. I guess you'd better have
it double-checked by a native speaker.
> Index: symtab.c
> ===================================================================
> --- symtab.c (revision 278293)
> +++ symtab.c (working copy)
> @@ -848,6 +848,8 @@ symtab_node::dump_base (FILE *f)
> fprintf (f, " transparent_alias");
> if (weakref)
> fprintf (f, " weakref");
> + if (symver)
> + fprintf (f, " symver");
> if (cpp_implicit_alias)
> fprintf (f, " cpp_implicit_alias");
> if (alias_target)
> @@ -1145,6 +1147,11 @@ symtab_node::verify_base (void)
> error ("node is transparent_alias but not an alias");
> error_found = true;
> }
> + if (symver && !alias)
> + {
> + error ("node is symver but not alias");
> + error_found = true;
> + }
> if (same_comdat_group)
> {
> symtab_node *n = same_comdat_group;
> @@ -1780,7 +1787,9 @@ symtab_node::resolve_alias (symtab_node
> if (target->get_comdat_group ())
> alias_alias->add_to_same_comdat_group (target);
> }
> - if (!alias_alias->transparent_alias || transparent)
> + if ((!alias_alias->transparent_alias
> + && !alias_alias->symver)
No need for the linebreak.
> + || transparent)
> {
> alias_alias->remove_all_references ();
> alias_alias->create_reference (target, IPA_REF_ALIAS, NULL);
> Index: varasm.c
> ===================================================================
> --- varasm.c (revision 278293)
> +++ varasm.c (working copy)
> @@ -1921,6 +1921,7 @@ assemble_end_function (tree decl, const
> switch_to_section (function_section (decl));
> ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
> #endif
> +
> if (! CONSTANT_POOL_BEFORE_FUNCTION)
> {
> output_constant_pool (fnname, decl);
> @@ -5960,6 +5961,23 @@ do_assemble_alias (tree decl, tree targe
> #endif
> }
>
> +/* Output .symver directive. */
> +
> +void
> +do_assemble_symver (tree decl, tree target)
> +{
> + tree id = DECL_ASSEMBLER_NAME (decl);
> + ultimate_transparent_alias_target (&id);
> + ultimate_transparent_alias_target (&target);
> +#ifdef ASM_OUTPUT_SYMVER_DIRECTIVE
> + ASM_OUTPUT_SYMVER_DIRECTIVE (asm_out_file,
> + IDENTIFIER_POINTER (target),
> + IDENTIFIER_POINTER (id));
> +#else
> + error ("symver is only supported on ELF platforms");
As I said, this is misleading: better say something like "not supported
in this configuration".
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University