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 functionality in the GCC 11 changes document. Some users might need to amend their source code to handle the fact that GCC can now place "used" decls in a new, unique section. Committed as obvious.
>From 7c56c86ebe102849ec239f0c57e93988169d90f4 Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz <joze...@mittosystems.com> Date: Mon, 7 Dec 2020 14:41:13 +0000 Subject: [PATCH] gcc-11/changes: "used" attribute saves decls from linker garbage collection --- htdocs/gcc-11/changes.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/gcc-11/changes.html b/htdocs/gcc-11/changes.html index ed289744..4d3efed5 100644 --- a/htdocs/gcc-11/changes.html +++ b/htdocs/gcc-11/changes.html @@ -158,6 +158,18 @@ a work-in-progress.</p> </li> </ul> </li> + <li> + For ELF targets that support the GNU or FreeBSD OSABIs, the + <code>used</code> attribute will now save the symbol declaration it is + applied to from linker garbage collection. + <br> + To support this behavior, <code>used</code> symbols that have not + been placed in specific sections (e.g. with the <code>section</code> + attribute, or the <code>-f{function,data}-sections</code> options) will + be placed in new, unique sections. + <br> + This functionality requires Binutils version 2.36 or later. + </li> </ul> <h3 id="cxx">C++</h3> -- 2.29.2