简体   繁体   English

用于控制,编辑或发出dylib的LC_UUID的工具吗?

[英]Tools to control, edit, or emit the LC_UUID of a dylib?

I'm producing dylibs with embedded bitcode and using the -bitcode-symbol-map flag to specify an output directory where files of the form UUID.bcsymbolmap get produced. 我正在生成带有嵌入式位码的dylib,并使用-bitcode-symbol-map标志指定一个输出目录,在该目录UUID.bcsymbolmap生成UUID.bcsymbolmap形式的文件。 I'd like to teach my build system about those bcsymbolmap files so I can install and package them, but it is hard to do so since the output name for the file is determined by the LC_UUID value in the dylib which seems to be determined by ld . 我想教我有关这些bcsymbolmap文件的构建系统,以便我可以安装和打包它们,但是这样做很难,因为该文件的输出名称由dylib中的LC_UUID值确定,该值似乎由ld It seems I have two choices: 看来我有两个选择:

  • Find a way to explicitly set the LC_UUID of the dylib when building it, so that I can predict the output name of the bcsymbolmap file. 找到一种在构建dylib时显式设置其LC_UUID的方法,以便可以预测bcsymbolmap文件的输出名称。

  • Specify a well known name for the bcsymbolmap file (the -bitcode-symbol-map option does support this) which does not contain the UUID, and then at install time, figure out the LC_UUID of the associated dylib and rename the bcsymbolmap file appropriately. 为不包含UUID的bcsymbolmap文件指定一个众所周知的名称( -bitcode-symbol-map选项支持此名称),然后在安装时找出关联的dylib的LC_UUID ,并适当地重命名bcsymbolmap文件。

However, I don't see either a linker flag that will let me specify the LC_UUID of the library when building it, or a tool to let me change it after the fact (thinking here of something like install_name_tool ), nor do I see a utility that will easily give me back the LC_UUID of a given library (to do the needed renaming of the bcsymbolmap file), short of parsing the output of otool -l , which seems fragile and unpleasant. 但是,我看不到一个链接器标志(使我在构建它时可以指定该库的LC_UUID ,或者一个可以让我在事后更改它的工具(在这里想到了诸如install_name_tool之类的东西),也看不到该实用程序可以轻松地给我返回给定库的LC_UUID (以进行bcsymbolmap文件的重命名),而otool -l解析otool -l的输出,这看起来很脆弱且令人不快。

I'd prefer to keep my options limited to things that ship with XCode. 我希望我的选择仅限于XCode附带的东西。 Does anyone know of tools to easily inject, edit, or emit the LC_UUID for a dylib? 是否有人知道可以轻松地为dylib注入,编辑或发出LC_UUID的工具?

Found something slightly better than parsing otool -l output: running dwarfdump -u on the target will list the UUIDs: 发现一些比解析otool -l输出更好的东西:在目标上运行dwarfdump -u将列出UUID:

$ dwarfdump -u build/libfoo.dylib
UUID: BF8FAFCC-5B1F-3FC8-B2AF-FCDA16609D71 (arm64) build/libfoo.dylib

It still isn't ideal, but at least is trivial to parse with awk or similar. 它仍然不是理想的,但是至少用awk或类似的语法解析起来并不容易。

Apple engineers, if anyone ever sees this, it would be very build system friendly to add an option to ld to explicitly set the LC_UUID at build time. Apple工程师,如果有人看到过这种情况,向ld添加选项以在构建时显式设置LC_UUID将对构建系统非常友好。 The flag -no_uuid already exists, it would seem easy to add a -uuid flag that took a UUID as an argument and used that instead of generating one. 标志-no_uuid已经存在,添加-uuid标志似乎很容易,该标志将UUID作为参数并使用它而不是生成一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM