Other Visibility-related Command-line Options


The -fminshared option specifies that the compilation unit will be part of a main program component and will not be linked as part of a shareable object. Since symbols defined in the main program cannot be preempted, this allows the compiler to treat symbols declared with default visibility as though they have protected visibility (i.e., -fminshared implies -fvisibility=protected).  Also, the compiler need not generate position-independent code for the main program.  It can use absolute addressing, which may reduce the size of the global offset table (GOT) and may reduce memory traffic.


The -fpic option specifies full symbol preemption.  Global symbol definitions as well as global symbol references get default (i.e., preemptable) visibility unless explicitly specified otherwise.


Normally a C/C++ file-scope declaration with no initializer and without the extern or static keyword

int i;

is represented as a common symbol.  Such a symbol is treated as an external reference, except that if no other compilation unit has a global definition for the name, the linker allocates memory for it. The -fno-common option causes the compiler to treat what otherwise would be common symbols as global definitions and to allocate memory for the symbol at compile time.  This may permit the compiler to use the more efficient GP-relative addressing mode when accessing the symbol.