Enables or disables the generation of position-independent code with relative address references, which are independent of the location where your program is loaded.
The default is
If you use
-fpic, then the compiler:
- Accesses all static data using PC-relative addressing.
- Accesses all imported or exported read-write data using a Global Offset Table (GOT) entry created by the linker.
- Accesses all read-only data relative to the PC.
Position-independent code compiled with
-fpic is suitable for
use in SysV and BPABI shared objects.
-fpic causes the compiler to invoke
--fpic option when performing the link step.
NoteWhen building a shared library, use
-fpictogether with either the
-fvisibilityoption or the visibility attribute, to control external visibility of functions and variables.