On Thu, Oct 09, 2003 at 12:08:55PM -0400, David Dawes wrote:
> On Thu, Oct 09, 2003 at 02:05:47PM +0200, Jakub Jelinek wrote:
> 
> >Looking at various /usr/X11R6/lib/lib*.so* shared libraries,
> >I'm seeing lots of exported symbols which look like they are exported
> >just because they cannot be static (as they are used by some other .o files
> >in the same shared library, but never by anything outside).
> 
> That is correct.
> 
> >If these could be classified (e.g. some _X* symbols in libX11.so.6,
> >some _Ice* symbols in libICE.so.6 etc. might fall into this category),
> >XFree86 could have smaller and faster shared libraries with less dynamic
> >relocations, which would not need to set up PIC pointer so often and use
> >less instructions to access shared library local variables (by bypassing
> >GOT on some arches).
> 
>  ... and it would discourage applications from using symbols that aren't
> part of the published interfaces.
> 
> I'd suggest starting with the library interface specs, exporting
> only those symbols that are documented as part of the interfaces,
> and seeing what applications break.  If a signficant number of
> applications do break, that might suggest adjusting the specs to
> agree with common usage.  I had plans of doing this with a linker
> version script, but it's still fairly low down on my todo list.
> >From an API point of view, I think it would be better to specify
> the symbols that should be public, rather than identifying all
> non-statics that shouldn't be.  It'd also be good if this could be
> implemented for as many of the platforms we support as possible.

Well, both version script and __attribute__((visibility ("hidden")))
can be used at the same time.
Anonymous version script works in 2001-12-18 and later binutils
and AFAIK in Solaris linker.  No idea about other arches.
If you think we should list all exported symbols, then maybe we
could introduce .sym (or .api) files for each library which would list
exported symbols one per line and Imakefile hacks to generate version
scripts/whatever else on the fly and use it during linking.
In addition to that, at least non-static but not exported variables
should be marked with X11_LIBRARY_LOCAL (or whatever other macro you prefer;
__HIDDEN__ is IMHO bad since it is OS implementation namespace),
for functions unless their address is taken it is much less important.

Now, is there some easy way how can the initial .api/.sym files be created
from the specs (exported headers or doc/specs or something else)?
When that's done, I can surely first see what other symbols other
XFree86 libraries need and then harvest some Everything install distribution
for other symbols.

Second thing is how to define Imakefile macros which will enable
__attribute__((visibility ("hidden"))) and/or version scripts.
Should they be just user settable, defaulting to no, or should
imake do the autodetection (for that it needs an autoconf like
test, since e.g. even when you have GCC 3.3 and later, still
visibility attribute doesn't have to be supported if that GCC
was compiled against old binutils, etc.)?

        Jakub
_______________________________________________
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel

Reply via email to