Skip to content
This repository was archived by the owner on Oct 19, 2025. It is now read-only.
This repository was archived by the owner on Oct 19, 2025. It is now read-only.

BeeHive的原理大概是这样子的 #139

@lyandy

Description

@lyandy

section

上图展示的是通过对编译链接完成生成的可执行文件分别查看Mach-O文件结构和反编译代码的结果

BeeHive的原理简单来说分为三步:
1、为了避免无用数据在编译阶段被优化删掉,就通过 used 来修饰 并告诉编译器把数据存到Mach-O文件的Segment Data 中,就是宏定义那段
2、hook动态链接库加载,在main函数执行之前把数据从Segment Data读取出来,做好class和protocol的字典对应准备,就是注册main函数执行之前__attribute__((constructor))那段
3、当程序启动完成后,就可以从字典的中根据protocol取出对应的类,达到解耦合的目的

再附上有关文章:
https://lowlevelbits.org/parsing-mach-o-files/
http://liumh.com/2018/08/18/ios-attribute-section/#section

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions