You copied the Doc URL to your clipboard.

-fpic, -fno-pic

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 -fno-pic.







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 armlink with the --fpic option when performing the link step.


When building a shared library, use -fpic together with either the -fvisibility option or the visibility attribute, to control external visibility of functions and variables.