fix target/15700

Jakub Jelinek jakub@redhat.com
Wed Mar 16 21:53:00 GMT 2005


On Wed, Mar 16, 2005 at 09:54:25AM -0800, Richard Henderson wrote:
> The following fixes the symbol alias definition problem wherein we fail 
> to emit symbols that are in fact needed.
> 
> It is now an error to define an alias to a symbol that isn't defined in
> the current translation unit.  It should have been an error before, but
> we didn't have code at the right places to detect the erroneous condition.

This will break the way libxml2, gtk2 etc. use aliases.
Do you have any ideas what to do there instead?

These packages want to do something similar to what glibc does, which is
basically symbols with usefully protected visibility.

Normal protected visibility is expensive, unlike hidden visibility it needs
handling in the dynamic linker to get function pointer equality right, and
in the dynamic linker it is actually even more expensive than handling of
symbols with normal visibility.

What glibc and libxml2/gtk2/etc. want for selected symbols is protected
visibility that does not guarantee pointer equality.  When a symbol is
declared with that visibility, the programmer guarantees it will be defined
in the same shared library (resp. binary) and all references to it within
that shared library should be treated as if the symbol was hidden.
But unlike hidden symbols, these need to be exported from the shared
libraries.

glibc uses a 2 macro approach, where a variable resp. function prototype
is first marked with a *hidden_proto macro in the header where it is
declared, and then below the definition of each such function resp.
variable there is another macro, *hidden_def.  These macros result
in a hidden alias being created for the symbols and the uses redirected
to the hidden alias (plus tricky part to deal with the actual function
definition).  With your recent glibc patch this should continue to work.

libxml2/gtk2 etc. want the same results, but would prefer if all
could be done in the headers, so that the changes are less intrusive
and more easily maintainable.

The current approach used e.g. in libxml2 is:

extern __typeof (xmlXPtrNewRangeNodes) xmlXPtrNewRangeNodes__internal_alias __attribute((visibility("hidden")));
extern __typeof (xmlXPtrNewRangeNodes) xmlXPtrNewRangeNodes __attribute((alias("xmlXPtrNewRangeNodes__internal_alias")));
#define xmlXPtrNewRangeNodes xmlXPtrNewRangeNodes__internal_alias

in a header for all symbols that are supposed to be handled that way.
This worked in GCC 3.4.x, ATM results in tons of warnings, but still works,
but once GCC requires the aliases to be defined in the same file
and visible to GCC, this will not work any longer.

	Jakub



More information about the Gcc-patches mailing list