portable-executable - 为什么 PE 格式位置依赖?

可执行文件需要首选加载地址并因此保留位置相关代码而不是简单地在整个文件中使用 RVA 是否有任何充分的理由?
对我来说,这看起来像是一个重大的设计缺陷,我不明白人们是怎么想出这个主意的。

最佳答案

我猜原因是历史原因多于实际原因。

引用 Matt Pietrek,来自他著名的“Peering Inside the PE”:

It's common knowledge that Windows NT has a VAX® VMS® and UNIX® heritage. Many of the Windows NT creators designed and coded for those platforms before coming to Microsoft. When it came time to design Windows NT, it was only natural that they tried to minimize their bootstrap time by using previously written and tested tools. The executable and object module format that these tools produced and worked with is called COFF (an acronym for Common Object File Format). [...] The COFF format by itself was a good starting point, but needed to be extended to meet all the needs of a modern operating system like Windows NT or Windows 95. The result of this updating is the Portable Executable format.

所以PE格式是基于COFF格式的,后面有relocations的概念: 它们允许系统(更准确地说是系统的加载器)通过修补位置相关地址来在运行时对 PE 进行 rebase 。

official PE documentation明确地将 Relocations 命名为“COFF Relocations”,所以我猜 PE 重定位是从 COFF 继承的,而不是 PE 格式本身带来的新添加。

总而言之,我的猜测是位置无关的 PE 被丢弃了(如果曾经考虑过的话),因为 COFF 格式已经有了实现相同功能的重定位概念。

https://stackoverflow.com/questions/29310696/

相关文章:

amazon-web-services - 如何防止使用签名网址从亚马逊云端下载视频

github - 如何查看用户的 github 拉取请求评论列表?

google-app-engine - Google App Engine 删除了默认的 GCS 存

erlang - tlsv1 警告 rabbitmq 安全性不足

kdb - 从包含空格字符的路径加载 file.q

php - Doctrine ManyToMany 优化许多查询

c# - 如何在使用 IDataErrorInfo 时检查模型是否有效或有错误

r - 如何可视化概率分布函数之间的差异?

dns - 为 DMARC 等将 DNS IN TXT 记录拆分为多行

ruby - 如何使 rake 任务依赖于文件和另一个任务