aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2005-11-09 20:13:41 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2005-11-09 20:13:41 +0000
commita0203ca711308b96d33acb895d4f7d254594287c (patch)
treecdc3a1f501856957bef831df0b91b2b381edd2b8 /gcc/doc
parent317adebb1faac58d50f0e44906aa18edaf663759 (diff)
downloadgcc-a0203ca711308b96d33acb895d4f7d254594287c.zip
gcc-a0203ca711308b96d33acb895d4f7d254594287c.tar.gz
gcc-a0203ca711308b96d33acb895d4f7d254594287c.tar.bz2
re PR other/4372 (#pragma weak pthread* inclusion causes applications to crash without a linker error when one forgets to link with -lpthread)
PR other/4372 * tree.h (IDENTIFIER_TRANSPARENT_ALIAS): New. (TREE_DEPRECATED): Adjust comment. Check for a DECL. * c-common.c (handle_weakref_attribute): New. (c_common_attribute_table): Add weakref. * configure.ac (HAVE_GAS_WEAKREF): Check for weakref support in the assembler. * configure, config.in: Rebuilt. * defaults.h (ASM_OUTPUT_WEAKREF): Define if HAVE_GAS_WEAKREF. * doc/extend.texi: Document weakref attribute. * varasm.c (ultimate_transparent_alias_target): New (assemble_name): Use it. (weak_finish_1): Split out of... (weak_finish): ... and deal with weakrefs in... (weakref_targets): ... new list. (globalize_decl): Clean up weakref_targets. (do_assemble_alias): Handle weakrefs. (finish_aliases_1): Do not reject weakrefs to external symbols. (assemble_alias): Handle weakrefs. From-SVN: r106703
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/extend.texi32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 52a8cc2..a796da6 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -2364,6 +2364,38 @@ also be used with non-function declarations. Weak symbols are supported
for ELF targets, and also for a.out targets when using the GNU assembler
and linker.
+@item weakref
+@itemx weakref ("@var{target}")
+@cindex @code{weakref} attribute
+The @code{weakref} attribute marks a declaration as a weak reference.
+Without arguments, it should be accompanied by an @code{alias} attribute
+naming the target symbol. Optionally, the @var{target} may be given as
+an argument to @code{weakref} itself. In either case, @code{weakref}
+implicitly marks the declaration as @code{weak}. Without a
+@var{target}, given as an argument to @code{weakref} or to @code{alias},
+@code{weakref} is equivalent to @code{weak}.
+
+@smallexample
+extern int x() __attribute__ ((weakref ("y")));
+/* is equivalent to... */
+extern int x() __attribute__ ((weak, weakref, alias ("y")));
+/* and to... */
+extern int x() __attribute__ ((weakref));
+extern int x() __attribute__ ((alias ("y")));
+@end smallexample
+
+A weak reference is an alias that does not by itself require a
+definition to be given for the target symbol. If the target symbol is
+only referenced through weak references, then the becomes a @code{weak}
+undefined symbol. If it is directly referenced, however, then such
+strong references prevail, and a definition will be required for the
+symbol, not necessarily in the same translation unit.
+
+The effect is equivalent to moving all references to the alias to a
+separate translation unit, renaming the alias to the aliased symbol,
+declaring it as weak, compiling the two separate translation units and
+performing a reloadable link on them.
+
@item externally_visible
@cindex @code{externally_visible} attribute.
This attribute, attached to a global variable or function nullify