Why isn't all code compiled position independent?

前端 未结 9 2522
感情败类
感情败类 2020-12-04 10:46

When compiling shared libraries in gcc the -fPIC option compiles the code as position independent. Is there any reason (performance or otherwise) why you would not compile

9条回答
  •  囚心锁ツ
    2020-12-04 11:30

    The question dates to 2009. Ten year have passed, and now all code is actually position independent. That is now enforced by operating systems and compilers. There is no way to opt-out. All code is force-compiled with PIE, and -no-pic/-no-pie flag is being ignored, as part of this ASLR excuse. The reason for that is to slow down formerly fast apps and sell newer hardware, under the guise of increased security. That is completely irrational, because now large memory sizes allow us to get rid of the hell of dynamic linking at all, compiling all apps statically.

    Same happened before, when people silently accepted real mode and other freedoms being taking away. And I mind you, MMU incurs heavy slowdown, due to context switches and address translation latency. You won't find MMU in performance critical systems, like those used by scientists to sample physics experiments.

    You don't complain, because you don't even know that your code is being handicapped by all these training wheels. What can I say? Enjoy 2 times slower software with their PIC now! Even more, with the advent of LLVM, soon there will be enforced JIT (managed code), with no access to x86 inline assembly, which will further slowdown any C/C++ code. "Those who sacrifice liberty for security deserve neither."

提交回复
热议问题