0

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?

  • What does `-s` do? It appears to be undocumented. – ams Apr 04 '14 at 16:16
  • @ams, why, it is in the gcc man page. `-s` strips relocation sections off binaries. –  Apr 05 '14 at 07:09
  • It's not on my GCC man page. I do see that on the linker man page, and it probably does get passed through. – ams Apr 07 '14 at 10:57

1 Answers1

0

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

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240