Mac OS X:估计代码和代码的最佳方法是什么? 程序的静态数据大小?

发布于 2024-07-04 17:48:48 字数 124 浏览 16 评论 0原文

我希望能够估算出有多少代码& 我的 C++ 程序使用静态数据?

有没有办法通过查看可执行文件或目标文件来找到这个问题? 或者也许我可以在运行时做一些事情?

otool 有帮助吗?

I want to be able to get an estimate of how much code & static data is used by my C++ program?

Is there a way to find this out by looking at the executable or object files? Or perhaps something I can do at runtime?

Will otool help?

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

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

发布评论

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

评论(2

旧话新听 2024-07-11 17:48:48
  • “size”是传统工具,适用于所有 UNIX 风格。
  • “otool”有更精细的粒度控制,并且有很多选项。

$ size python
__TEXT  __DATA  __OBJC  others  dec     hex
860160  159744  0       2453504 3473408 350000
  • "size" is the traditional tool and works on all unix flavors.
  • "otool" has a bit finer grain control and has a lot of options.

.

$ size python
__TEXT  __DATA  __OBJC  others  dec     hex
860160  159744  0       2453504 3473408 350000
场罚期间 2024-07-11 17:48:48

我认为 otool 可以提供帮助。 具体来说,“otool -s {segment} {section}”应该打印出详细信息。 我不确定您是否可以在不指定部分的情况下获取有关 __DATA 或 __TEXT 的信息。 也许这些大小在 mach 标头中报告:“otool -h”?

otool -s  __DATA __data MyApp.bundle/Contents/MacOS/MyApp
otool -s __TEXT __text MyApp.bundle/Contents/MacOS/MyApp

无论如何,Apple 在这里记录了每个段复制到每个部分的内容: Apple 的 mach-o 格式文档

I think otool can help. Specifically, "otool -s {segment} {section}" should print out the details. I'm not sure if you can get information about __DATA or __TEXT without specifying a section. Maybe those sizes are reported in the mach header: "otool -h"?

otool -s  __DATA __data MyApp.bundle/Contents/MacOS/MyApp
otool -s __TEXT __text MyApp.bundle/Contents/MacOS/MyApp

Anyway, Apple documents what gets copied into each section per-segment here: Apple's mach-o format documentation

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