Search code examples
gccaslrfpic

Both -fPIC and -s used - possibly contradictory?


In a particular project, I saw the following compiler options used all at once:

gcc foo.c -o foo.o -Icomponent1/subcomponent1 -Icomponent2/subcomponent1 -Wall -fPIC -s

Are the -fPIC and -s used together contradictory here? If not, why?


Solution

  • -s and -fPIC are two flags used for different purposes. They are not contradictory.

    From the gcc manual

    -s Remove all symbol table and relocation information from the executable.

    -fPIC If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table. This option makes a difference on the m68k, PowerPC and SPARC.