iOS 解析命令:otool -

2025-03-06  本文已影响0人  lukyy
二进制文件Header(文件头)

包含文件的基本信息,如文件类型(可执行文件、动态库等)、CPU 架构(arm64、x86_64 等)、加载命令的数量等。
通过命令可以查看文件头信息。

otool -h <binary>  //查看文件头信息
//示例:
//假设你有一个 iOS App 的可执行文件 MyApp,路径为 /Users/username/MyApp.app/MyApp,你可以运行以下命令查看文件头信息:
otool -h /Users/username/MyApp.app/MyApp

otool -l <binary>  //查看加载命令
otool -L <binary>  //查看依赖的动态库
otool -tV <binary> //查看代码段的反汇编
otool -s __DATA __data <binary> //查看数据段的内容

otool -h 的作用

otool -h 用于显示 Mach-O 文件的文件头信息。文件头包含以下关键信息:

输出示例

运行 otool -h 后,你会看到类似以下的输出:

Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  ARM64        ALL  0x00     EXECUTE    28       4048   NOUNDEFS DYLDLINK TWOLEVEL PIE
字段说明:

具体案例

输出的内容如下:Mach header(对照以上说明,可以明白具体含义)

      magic  cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
 0xfeedfacf 16777228          0  0x00           2   119      11976 0x00218085 
上一篇 下一篇

猜你喜欢

热点阅读