开发者

Why can a shared library created from non-pic object work?

I'm confused. 开发者_高级运维I try in Linux on x86.


PIC just makes live more simple for the loader since it only has to modify a few global addresses in the code. Non-PIC code just contains a lot more of these addresses, so the table with addresses which need relocation are bigger. But the loader must be able to relocate the code in either case (for example, to resolve the addresses of static/global variables and all function pointers).


x86 ABI kind of supports non-PIC code in shared libraries. As pointed out before it means pages that will normally be shared will not be shared (because ld.so needs to patch references in code rather special place (GOT)).

But libraries built that way may be a bit faster, because PIC code is generally slower.

amd64 ABI does not support that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜