[llvm-dev] Adding bitcode to an existing MachO object file

Joseph via llvm-dev llvm-dev at lists.llvm.org
Sat Aug 15 06:53:04 PDT 2020


This is a silly question, but I am in a situation where I need to build x86
and arm assembly sources for some sources while the rest will be built with
C. I do know that just adding `-fembed-bitcode` to a C sources would embed
bitcode, but doing the same for the assembly files will not do that (at
least, it will add the 1-byte `_LLVM,__asm` section, but not the
`__LLVM,__bitcode` section). Furthermore, I do need the final output to
contain bitcode for all files used.

So, my question is if it is possible to add the `__LLVM,__bitcode` section
later to the MachO object file. I tried to archive the bitcode using `xar`
and run `llvm-objcopy main.o --add-section=__LLVM,__bitcode=main.xar
main2.o`, but it failed with an `unsupported load command`. This seems to
be the case for all usages of `llvm-objcopy` with MachO files.

Cheers and thanks

-- Joseph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200815/2d88c9cc/attachment.html>


More information about the llvm-dev mailing list