[Bug other/15000] Support setting the default symbol visibility for ELF

bryner at brianryner dot com gcc-bugzilla@gcc.gnu.org
Sun Apr 18 13:37:00 GMT 2004


------- Additional Comments From bryner at brianryner dot com  2004-04-18 04:27 -------
(in response to bug 9283, comment #18):
> I also changed how visibility is taken into account when making a symbol local 
> which lets the compiler and optimiser work better. Basically anything which 
> doesn't have default visibility is made local. I also made all inlineable code 
> always the -fvisibility setting no matter what and a few other things.

I'm confused by your local_p change, actually.  I don't see how it changes the
current behavior at all... it appears to already be setting local_p=true for
decls with DECL_VISIBILITY != VISIBILITY_DEFAULT.


> No, I modified the function which creates a new decl to simply set the 
> visibility to whatever the command line arg specified. This causes all decls to 
> be that visibility by default which is just what we want. There are no knock-on 

If you treat a symbol in an external DSO as hidden visibility, the compiler will
not generate a PLT jump for that function call, and the linker will be forced to
generate a text section relocation.  I'm pretty sure that's bad (prevents
sharing of the text section across processes).  So I really think we need to
provide an easy way for the user to ensure that declarations of functions in
external DSOs are treated as default visibility.

Implementing -fvisibility-default _efficiently_ may be difficult.  We don't want
to have to generate the assembler name for each decl we encounter to check if
it's one with visibility overridden.  It would be better if we could generate a
lookup table from the symbol file which could be compared against the decl
without any additional string manipulation or allocations.  I think for C that
just means comparing the DECL_NAMEs; for C++ the DECL_NAME doesn't uniquely
identify the resulting symbol so we'd need to extract all of the relevant info
from the mangled symbol name.

One idea that _doesn't_ require implementing -fvisibility-default= is to
generate and use a precompiled header that brings in all of the declarations for
those functions and compile the header without -fvisibility=hidden.  Or, along
the same lines, implement some construct you can wrap #includes with to say that
the header declares functions that have default visibility.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15000



More information about the Gcc-bugs mailing list