Since 6fbec038f7a, the "used" attribute will save the symbol declaration
it is applied to from linker garbage collection, if the target supports
the SHF_GNU_RETAIN section flag.

This patch documents this new functionality.

Committed as obvious.
>From 724390745213d5192af04a51bb08cf44da7c396d Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <joze...@mittosystems.com>
Date: Mon, 7 Dec 2020 14:26:46 +0000
Subject: [PATCH] doc: "used" attribute saves decls from linker garbage
 collection

gcc/ChangeLog:

        * doc/extend.texi (used function attribute): Document saving
        the declaration from linker garbage collection.
        (used variable attribute): Likewise.
---
 gcc/doc/extend.texi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index fd282aa0157..0c969085d1f 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -3859,6 +3859,14 @@ When applied to a member function of a C++ class 
template, the
 attribute also means that the function is instantiated if the
 class itself is instantiated.
 
+For ELF targets that support the GNU or FreeBSD OSABIs, this attribute
+will also save the function from linker garbage collection.  To support
+this behavior, functions that have not been placed in specific sections
+(e.g. by the @code{section} attribute, or the @code{-ffunction-sections}
+option), will be placed in new, unique sections.
+
+This additional functionality requires Binutils version 2.36 or later.
+
 @item visibility ("@var{visibility_type}")
 @cindex @code{visibility} function attribute
 This attribute affects the linkage of the declaration to which it is attached.
@@ -7420,6 +7428,14 @@ When applied to a static data member of a C++ class 
template, the
 attribute also means that the member is instantiated if the
 class itself is instantiated.
 
+For ELF targets that support the GNU or FreeBSD OSABIs, this attribute
+will also save the variable from linker garbage collection.  To support
+this behavior, variables that have not been placed in specific sections
+(e.g. by the @code{section} attribute, or the @code{-fdata-sections} option),
+will be placed in new, unique sections.
+
+This additional functionality requires Binutils version 2.36 or later.
+
 @item vector_size (@var{bytes})
 @cindex @code{vector_size} variable attribute
 This attribute specifies the vector size for the type of the declared
-- 
2.29.2

Reply via email to