如何在 llvm 中链接 elf 静态库?
我有一个 lib (*.a) 文件,是用 armcc 以 elf 格式创建的。无法使用 llvm 或 gcc 重新编译它。 (它是为armcc编写的汇编程序)。
将其与 gnu ld 链接在 Linux 上运行良好,但在 Mac 上使用 llvm 进行链接时遇到问题。
由于 obj 文件的内部格式不同,它会显示“忽略文件...这不是正在链接的架构”
是否有解决方法?一种将 elf 转换为 Mach-O 格式的方法?告诉 llvm 有关 elf 的信息?
有这样一个用于 x86/86-64 的 工具,由 Agner Fog 编写,但我是正在寻找 ARM 工具。
I have a lib (*.a) file, created with armcc in the elf format. There is no possibility to recompile it with llvm or gcc. (It's assembler written for armcc).
Linking it with the gnu ld works fine on Linux, but I have problems doing it on Mac, with llvm.
Because of the different internal format for obj files, it will say "Ignoring file ... which is not the architecture being linked"
Is there a workaround for this? A way to convert elf to Mach-O format? To tell llvm about elf?
There is such a tool for x86/86-64, written by Agner Fog, but I am looking for an ARM tool.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
binutils 有一个 objcopy,它应该将二进制文件从一种格式转换为另一种格式。我认为,您应该使用 Linux 和 iOS BFD 编译 binutils。不幸的是,binutils 对 Mach-O 的支持并不完整(有一些关于 ARM+objcopy+Mach-O 的负面报道)。
另请参阅:
另一种转换方法是进行重新组装(从 .a 存档中拆解每个 .o 文件并使用 Mach-O 重新组装) -兼容的汇编器)。
There is an objcopy from binutils, which should convert binary from one format to another. I think, you should have binutils compiled with both Linux and iOS BFDs. Unfortunately, binutils's support of Mach-O was incomplete (there are some negative reports about ARM+objcopy+Mach-O).
See also:
Other way of converting is to do a reassembly (disassemble each .o file from .a archive and reassemble it with Mach-O-compatible assembler).