Re: used vs retain attribute

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

 



Hi,

on 2021/7/5 上午1:31, NightStrike via Gcc-help wrote:
> Which of these is correct?
> 

IIUC the quoted content in gcc-11 changes is stale and wrong.
Good catch!

> 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.
> 

The above note was meant for the change introduced by commit [1].
But later commit [2] introduced attribute "retain" and recovered the
behavior of attribute "used".  So I'm afraid that the above note
has to be removed to avoid any confusions.

CC Jozef.

BR,
Kewen

[1] https://gcc.gnu.org/git/gcc.git/6fbec038f7a7ddf29f074943611b53210d17c40c
[2] https://gcc.gnu.org/git/gcc.git/6347f4a0904fce17eedf5c071be6f3c118680290



[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