Why isn't all code compiled position independent?

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

    It adds an indirection. With position independent code you have to load the address of your function and then jump to it. Normally the address of the function is already present in the instruction stream.

提交回复
热议问题