为什么不是所有的code编译位置无关? [英] Why isn't all code compiled position independent?

查看:155
本文介绍了为什么不是所有的code编译位置无关?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在海湾合作委员会的-fPIC选项编译共享库编译code作为独立的立场。是否有你为什么会不编译独立于所有code位置的任何原因(性能或其他方式)?

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 all code position independent?

推荐答案

它增加了一个间接。与位置无关code,你必须加载函数的地址,然后跳转到它。通常该函数的地址已present指令流中

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.

这篇关于为什么不是所有的code编译位置无关?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆