Bug 85692

Summary: Visibility reference doesn't work.
Product: [Retired] Red Hat Linux Reporter: hjl
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 9   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://www.caldera.com/developers/gabi/latest/ch4.symtab.html#symbol_value
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-03 12:41:29 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description hjl 2003-03-06 00:49:21 UTC
According to gABI:

First, all of the non-default visibility attributes, when applied to a symbol 
reference, imply that a definition to satisfy that reference must be provided 
within the current executable or shared object. If such a symbol reference has 
no definition within the component being linked, then the reference must have 
STB_WEAK binding and is resolved to zero. 

it is ok to have

extern int short_hidden_ref_norm_def __attribute__ ((visibility ("hidden")));

int main()
  printf ("%d\n", short_hidden_ref_norm_def);
  return 0;

But gcc 3.2.1-7 doesn't make short_hidden_ref_norm_def as hidden.

Comment 1 Jakub Jelinek 2003-03-09 22:25:03 UTC
That's on purpose. When you use visibility attribute on an external, you
guarantee that either you use the same attribute on the symbol definition,
or that you make the symbol .hidden in some other way (e.g. in assembly).
Initially, visibility attribute added .hidden even for external references,
but that created more problems than it was worth, so it was changed this way.

Comment 2 hjl 2003-03-10 00:37:24 UTC
I believe the bug is in ld, not gcc. I am working on ld
to make it compliant to gABI. Right now, ld doesn't follow

Comment 3 hjl 2003-05-15 19:12:11 UTC
The gABI allows weak undefined hidden/protected symbols.
Visibility information may also help linker. Gcc emits
weak undefined symbols. I think it should do the same for
hidden/protected symbols.