Windows 可移植可执行文件如何跨机器体系结构移植
Windows 可移植可执行文件真的可以跨机器架构移植吗?如果是这样,它是如何运作的?如果不是,那么“可移植可执行文件”是什么意思或者可执行文件的哪一部分是可移植的?
谢谢,西瓦钱德兰
Is Windows Portable Executables are really portable across machine architectures? If so how it works? If not then what does "Portable Executable" mean or which part of executable is portable?
Thanks, Siva Chandran
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
可执行文件本身不可移植。 PE 格式是“可移植的”,因为不同体系结构的可执行文件使用相同的 PE 格式,但 PE 文件中的可执行代码特定于单个处理器体系结构。
实际上,这意味着许多相同的编译器和链接器代码可以重用于不同的体系结构,并且用于检查可执行文件的工具可以(在某种程度上)适用于“外部”可执行文件。
(我在这里谈论的是本机可执行文件 - .NET 程序集也使用 PE 格式并且可以真正可移植。)
The executables aren't themselves portable. PE format is "portable" in the sense that executables for different architectures use the same PE format, but the executable code within a PE file is specific to a single processor architecture.
In practice this means that a lot of the same compiler and linker code can be reused for different architectures, and that tools for examining executables can (to some extent) work for "foreign" executables.
(I'm talking about native executables here - .NET assemblies also use PE format and can be truly portable.)
来自维基百科:
“术语‘可移植’是指该格式在多种操作系统软件架构环境中的多功能性。”
http://en.wikipedia.org/wiki/Portable_Executable
From Wikipedia:
"The term "portable" refers to the format's versatility in numerous environments of operating system software architecture."
http://en.wikipedia.org/wiki/Portable_Executable
嗯,它是可移植的,因为该格式可用于各种平台上的可执行文件(SkyOS 在切换到 ELF 之前就使用了它)。它不能通过独立于平台的代码进行移植,或者如果您在一个操作系统上生成一个 PE 文件,那么它可以在另一个操作系统上运行。
Well, it is portable in means of that the format can be used for executables on various platforms (SkyOS used it before they switched to ELF). It is not portable in means of platform independent code or that if you produce a PE file on one OS that it runs on another.
PE 文件只是二进制应用程序数据的容器。
它们允许针对不同的 CPU 架构(甚至非 CPU 软件架构,如 .Net)。这就是为什么它们被称为“便携式”。
然而,它们包含的每个二进制应用程序映像都只适合一种架构。
PE-files are just containers for binary application data.
They allow to target different CPU architectures (or even non-CPU software architectures like .Net). That is why they are called "portable".
Each binary application image they contain, however is suited for exactly one architecture.