Should it -fPICnever be used when creating an executable or static library?
It is never a strong word, and the above statement is false.
Code built with -fPIC(a little) is less than optimal, so why do you want to put it in something other than a shared library?
Let's start with a static library that has a simple answer.
, , , ?
3 ( -fPIC , -fPIE PIE "" ), ( , -fPIC).
, , 2 , .
, (-PIE) . -fPIC ?
, , , . , , PIE non-PIE.
3 ( -fPIC, -fPIE), ( -fPIC) , PIE -PIE . .
TL; DR: -fPIC , , ( ).
Update:
.
- ?
: .
. , . .text ( .rodata).