问题 如何将数据嵌入到Mac OS X mach-o二进制文件的TEXT部分?


我有一个Mac OS X命令行工具,可以从二进制文件本身嵌入一些数据中受益。

我知道mach-o文件支持多个段,其中一些可用于存储任意数据。但我找不到一个命令行工具来做到这一点。

虽然我知道还有其他的,可能更简单的方法(例如将数据文件转换为C源代码并通过gcc链接)以将数据导入我的二进制文件,这个问题引起了我的兴趣。有谁知道魔术?


9168
2017-10-22 02:07


起源



答案:


链接器ld采用参数-sectcreate。

从手册页中,

 -sectcreate segname sectname file
             The section sectname in the segment segname is created from
             the contents of file file. The combination of segname and 
             sectname must be unique  there cannot already be a 
             section (segname,sectname) from any other input.

海湾合作委员会也有一个 部分 可以应用于变量的属性,表示它属于非标准部分。


12
2017-10-22 05:47



卫生署。回想起来很明显。谢谢。 - schwa


答案:


链接器ld采用参数-sectcreate。

从手册页中,

 -sectcreate segname sectname file
             The section sectname in the segment segname is created from
             the contents of file file. The combination of segname and 
             sectname must be unique  there cannot already be a 
             section (segname,sectname) from any other input.

海湾合作委员会也有一个 部分 可以应用于变量的属性,表示它属于非标准部分。


12
2017-10-22 05:47



卫生署。回想起来很明显。谢谢。 - schwa