This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Visibility attribute


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]