Why does gcc force PIC for x64 shared libs?
问题 Trying to compile non-PIC code into a shared library on x64 with gcc results in an error, something like: /usr/bin/ld: /tmp/ccQ2ttcT.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC This question is about why this is so. I know that x64 has RIP-relative addressing which was designed to make PIC code more efficient. However, this doesn't mean load-time relocation can't be (in theory) applied to such code. Some online sources,