位置独立代码与可重定位代码 [英] Position Independant Code vs Relocatable code

查看:402
本文介绍了位置独立代码与可重定位代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

位置无关代码与可重定位代码之间的区别是什么?谁负责生成位置无关代码(PIC)和可重定位代码(比如编译器/链接器/加载器)。是否所有编译器/链接器都支持PIC生成和重定位?

What is exactly the difference between the position independant code and Relocatable code. Who is responsible for generating the position independant code(PIC) and Relocatable code(say compiler/linker/loader). Does all compiler/linker supports PIC generation and relocation?

推荐答案

位置无关代码和可重定位代码之间的区别是什么。

如有疑问,请咨询维基百科: https://en.wikipedia.org/wiki/与职位无关的代码 [ ^ ]

与位置无关的代码(PIC)或与位置无关的可执行文件(PIE)是机器代码的一部分,无论其绝对地址如何都位于主存储器中的某个位置

...

这与可重定位代码不同,在可重定位代码中,链接编辑器或程序加载器在执行之前修改程序,因此它只能从特定的内存位置运行。 i>



所有编译器/链接器是否支持PIC生成和重定位on?

No.

现代的,但很旧的可能没有。
"What is exactly the difference between the position independant code and Relocatable code."
If in doubt, ask Wikipedia: https://en.wikipedia.org/wiki/Position-independent_code[^]
" position-independent code (PIC) or position-independent executable (PIE) is a body of machine code that, being placed somewhere in the primary memory, executes properly regardless of its absolute address
...
This differs from relocatable code, in which a link editor or program loader modifies a program before execution so it can be run only from a particular memory location. "


Does all compiler/linker supports PIC generation and relocation?
No.
Modern ones do, but very old ones may not.


这篇关于位置独立代码与可重定位代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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