Why isn't all code compiled position independent?

前端 未结 9 2498
感情败类
感情败类 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:16

    Also, virtual memory hardware in most modern processors (used by most modern OSes) means that lots of code (all user space apps, barring quirky use of mmap or the like) doesn't need to be position independent. Every program gets its own address space which it thinks starts at zero.

提交回复
热议问题