【问题标题】:How to understand the comments about fat_arch_64 in 'mach-o/fat.h'如何理解'mach-o/fat.h'中关于fat_arch_64的评论
【发布时间】:2021-01-15 05:50:47
【问题描述】:

最近在学习一些Mach-O相关的资料,注意到评论

当切片大于 4mb 或切片的偏移量大于 4mb 时,使用 64 位 fat 文件格式。

'mach-o/fat.h' 关于struct fat_acrh_64

我知道我们应该使用fat_header.magic 的值来决定使用fat_archfat_arch_64 来解析胖文件中的数据。

但我对评论感到困惑,为什么限制条件是4 Mb,评论中的slice/offset是什么意思?

头文件截图如下:

【问题讨论】:

    标签: ios macos mach-o universal-binary fat-binaries


    【解决方案1】:

    评论有误,你可以在野外找到反例。
    这是来自 M1 Mac:

    % otool -f /usr/sbin/php-fpm
    Fat headers
    fat_magic 0xcafebabe
    nfat_arch 2
    architecture 0
        cputype 16777223
        cpusubtype 3
        capabilities 0x0
        offset 16384
        size 14061120
        align 2^14 (16384)
    architecture 1
        cputype 16777228
        cpusubtype 2
        capabilities 0x80
        offset 14090240
        size 14110192
        align 2^15 (32768)
    

    如您所见,大小和偏移量都超过了 14MB。

    一个合理的猜测是它们的意思是 4GB,这是 uint32 可以表示的限制。

    【讨论】:

    猜你喜欢
    • 2020-09-22
    • 2013-01-21
    • 1970-01-01
    • 2022-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-29
    • 1970-01-01
    相关资源
    最近更新 更多