used vs retain attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Which of these is correct?

1) The manual states:

used

This attribute, attached to a variable with static storage, means that
the variable must be emitted even if it appears that the variable is
not referenced.

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.

retain

For ELF targets that support the GNU or FreeBSD OSABIs, this attribute
will save the variable from linker garbage collection. To support this
behavior, variables that have not been placed in specific sections
(e.g. by the section attribute, or the -fdata-sections option), will
be placed in new, unique sections.

This additional functionality requires Binutils version 2.36 or later.




2) The gcc 11 changes website (https://gcc.gnu.org/gcc-11/changes.html) states:

For ELF targets that support the GNU or FreeBSD OSABIs, the used
attribute will now save the symbol declaration it is applied to from
linker garbage collection.

To support this behavior, used symbols that have not been placed in
specific sections (e.g. with the section attribute, or the
-f{function,data}-sections options) will be placed in new, unique
sections.

This functionality requires Binutils version 2.36 or later.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux