Linker script vs. visibility patch
Karl Vogel
karl.vogel at seagha.com
Wed Jul 21 16:47:58 CEST 2004
Karl Vogel wrote:
> kdemacros.h :
> -#define KDE_EXPORT __attribute__ ((visibility("visible")))
> +#define KDE_EXPORT __attribute__ ((visibility("default")))
Note: this looks like an error in KDE.. as GCC doesn't know a visibility of
"visible" !
==== GCC Info page:
`visibility ("VISIBILITY_TYPE")'
The `visibility' attribute on ELF targets causes the declaration
to be emitted with default, hidden, protected or internal
visibility.
void __attribute__ ((visibility ("protected")))
f () { /* Do something. */; }
int i __attribute__ ((visibility ("hidden")));
See the ELF gABI for complete details, but the short story is:
"default"
Default visibility is the normal case for ELF. This value is
available for the visibility attribute to override other
options that may change the assumed visibility of symbols.
"hidden"
Hidden visibility indicates that the symbol will not be
placed into the dynamic symbol table, so no other "module"
(executable or shared library) can reference it directly.
"protected"
Protected visibility indicates that the symbol will be placed
in the dynamic symbol table, but that references within the
defining module will bind to the local symbol. That is, the
symbol cannot be overridden by another module.
"internal"
Internal visibility is like hidden visibility, but with
additional processor specific semantics. Unless otherwise
specified by the psABI, gcc defines internal visibility to
mean that the function is never called from another module.
Note that hidden symbols, while they cannot be referenced
directly by other modules, can be referenced indirectly via
function pointers. By indicating that a symbol cannot be
called from outside the module, gcc may for instance omit the
load of a PIC register since it is known that the calling
function loaded the correct value.
Not all ELF targets support this attribute.
====
Also.. I noticed that the Intel C++ Compiler for Linux already supports the
-fvisibility option to set the default to hidden:
http://www.intel.com/software/products/compilers/clin/docs/ug/lin1005.htm
More information about the Kde-optimize
mailing list