This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Visibility attribute
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Matt Austern <austern at apple dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 25 Nov 2003 22:58:45 -0800
- Subject: Re: Visibility attribute
- References: <FCFC725B-1FD1-11D8-8A76-000393B2ABA2@apple.com>
On Tue, Nov 25, 2003 at 09:32:56PM -0800, Matt Austern wrote:
> My patch that introduced DECL_VISIBILITY broke the visibility feature
> for C; see PR c/13134. I definitely need to fix the compiler, and I
> have a patch that does fix things for certain definitions of "fix".
> But before I submit it, I'd like to get some feedback on what the
> semantics of this feature actually ought to be. As usual, the manual
> isn't quite specific enough to be sure. Depending on what we decide,
> it might be that the right solution will be for me to back out my patch
> entirely.
>
> There are two fundamental questions:
> 1. If you have multiple declarations of the same function or variable,
> may you give them different visibilities? If so, what should be the
> semantics?
The ELF gABI specifies:
Second, if any reference to or definition of a name is a symbol with a
non-default visibility attribute, the visibility attribute must be propagated
to the resolving symbol in the linked object. If different visibility
attributes are specified for distinct references to or definitions of a symbol,
the most constraining visibility attribute must be propagated to the resolving
symbol in the linked object. The attributes, ordered from least to most
constraining, are: STV_PROTECTED, STV_HIDDEN and STV_INTERNAL.
BTW, it will be nice to support
extern __attribute__ ((visibility("hidden"))) int x;
gcc can take advantage of it. Also, some compilers support "extern"
visibility, that is the symbol isn't defined in the current executable
or shared object.
H.J.