程序如何同时支持i386和ppc?

发布于 2024-07-27 19:55:36 字数 425 浏览 4 评论 0原文

我想知道 /bin 上的程序如何支持 i386 和 ppc 架构。

我运行例如

bin  $ file amber

我得到

amber: setgid Mach-O universal binary with 2 architectures
amber (for architecture i386):  Mach-O executable i386
amber (for architecture ppc):   Mach-O executable ppc

程序如何在源代码中支持i386和ppc?

换句话说,您可以删除哪些组件,例如,如果您删除了/bin/amber中的支持 ppc 架构吗?

I would like to know how you can support i386 and ppc architectures for programs at /bin.

I run for instance

bin  $ file amber

I get

amber: setgid Mach-O universal binary with 2 architectures
amber (for architecture i386):  Mach-O executable i386
amber (for architecture ppc):   Mach-O executable ppc

How do programs support i386 and ppc in the source code?

In other words, which components can you remove, for instance, in /bin/amber if you remove the support of ppc -architecture?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

Hello爱情风 2024-08-03 19:55:36

它称为通用二进制。 简而言之,可执行文件包含两种类型的可执行代码。 Apple 有一个已发布文档,描述开发人员应如何构建应用程序在任一平台上运行。

可执行文件 lipo 可用于从文件中删除任一版本的可执行文件。 如果您希望可执行文件仅包含一个版本,则可以使用 lipo 来实现此目的。

请注意,不仅仅是 ppci386,尽管这些是为通用二进制文件选择的“最安全”架构。 阅读 拱形; 在那里您可以看到现代 OSX 二进制文件可能包含 ppcppc64i386x86_64 中的任何一个。 还列出了更多内容,但它们的存在是为了完整性。

It's called a Universal binary. In short, the executable contains both types of executable code. Apple has a published document describing how developers should build their applications to run on either platform.

The executable lipo can be used to remove either version of the executable from the file. If you want your executables to contain only one version, you can use lipo to achieve this.

Be aware that there is more than just ppc and i386, although these are the "safest" architectures to choose for a Universal binary. Read the manpage for arch; there you can see that a modern OSX binary is likely to contain any of ppc, ppc64, i386 or x86_64. There are many more listed, but they exist there for completeness.

桜花祭 2024-08-03 19:55:36

它称为 fat 二进制文件

二进制文件中有两种架构的本机代码的副本。 二进制格式和操作系统必须支持它,这样它才能知道在文件中的何处查找正确的代码。

It's called a fat binary.

There's a copy of the native code for both architectures in the binary. The binary format and the operating system have to support it, so it can know where to look in the file for the correct code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文