otool“帽子”的含义场地

发布于 2024-10-06 16:40:16 字数 338 浏览 6 评论 0原文

当我运行 otool -favh some/library.so 时,会出现以下字段:

Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  X86_64        ALL LIB64     EXECUTE    12       1552   NOUNDEFS DYLDLINK TWOLEVEL
  • “caps”列的含义是什么?
  • caps 列不同会导致链接失败吗?

When I run otool -favh some/library.so there are the following fields:

Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  X86_64        ALL LIB64     EXECUTE    12       1552   NOUNDEFS DYLDLINK TWOLEVEL
  • What is the meaning of the "caps" column?
  • Would the caps column being different cause linking failures?

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

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

发布评论

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

评论(1

作妖 2024-10-13 16:40:16

好问题。似乎没有任何地方记录。不过,由于开源,答案可以在 otools 的源代码中找到,因此如果您需要更多信息,可以查看那里。

该字段表示CPU的能力位(即cpusubtype & CPU_SUBTYPE_MASK)。所以我想它实际上是 cpusubtype 字段的子集,以使该信息更容易获得。它是 otools 程序员放入的东西,而不是 Mach-O 标头的一部分。

caps 列是否会有所不同
导致链接失败?

不确定我是否在这里收到你的问题,链接到底是什么?显然,为不同的处理器编译两个库(因此可能具有不同的“caps”字段)并尝试将它们链接在一起可能是一个问题。不过,在这方面,我更关心“cputype”字段。如果您将 x86 代码与 ARM 代码链接(我猜比“caps”字段更重要),它可能会给您一个提示。

一般来说,我不会过多地关注一个没有人愿意在任何文档中提及的领域,除非您的特殊情况需要这样做。

Good question. Not documented anywhere, it seems. Thanks to open-source, though, the answer was available in the source code for otools, so you can look there if you need more information.

The field represents the capability bits of the CPU (that is cpusubtype & CPU_SUBTYPE_MASK). So it is really a subset of the cpusubtype field, to make that information more readily available, I suppose. It is something the otools programmer(s) put in, and not a part of the Mach-O header.

Would the caps column being different
cause linking failures?

Not sure if I get your question here, linking what exactly? Having two libraries compiled for different processors (thus possibly with different "caps" fields) and trying to link them together might be an issue, obviously. I would be more concerned with the "cputype" field in that regard, though. It will probably give you a hint if you are linking x86 code with ARM code (more so than the "caps" field, I'd guess).

In general, I would not concentrate too much on a field that nobody even cares to mention in any documentation, unless your particular situation demands it.

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