[Ffmpeg-devel] [patch] gcc4 visibility support
matthieu castet
castet.matthieu
Fri Jun 2 18:40:37 CEST 2006
Mike Melanson wrote:
> Luca Barbato wrote:
>
>> Diego Petten? started adding support for gcc visibility on every
>> application he could touch, including ffmpeg.
>>
>> Looks ok and helped already to find application playing with private
>> symbols. (should also trim a bit the binary size)
>
>
> Could you explain this a bit? What is meant by "gcc visibility"? A
> cursory review of the patch seems to indicate that public symbols in the
> C files are now qualified with the keyword EXPORTED. What's this all
> about? I haven't heard of this before.
>
http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Function-Attributes.html#Function-Attributes
in sumary it allow to hide global variable to others libraries and allow
to avoid symbol clash :
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.
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.
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.
Not all ELF targets support this attribute.
More information about the ffmpeg-devel
mailing list