An objcopy equivalent for Mac / iPhone?

耗尽温柔 提交于 2019-11-29 05:30:24
synthesizerpatel

Sounds like a job for Agner Fog's objconv.

From the announcement:

I have now finished making full support for Mach-O files in the object file converter mentioned in my previous posts. You may use it as a replacement for the missing objcopy utility.

Objconv can be used for the following purposes:
Convert object files and library/archive files between Mach-O, ELF, COFF and OMF formats for all x86 and x86-64 platforms.

Change symbol names in object files, make symbols weak, add alias names to symbols.

Build, modify and convert static library files (*.a, *.lib) across platforms (Mac, Linux, BSD, Windows)

Dump object files and executable files

Disassemble object files and executable files. Very good disassembler.

I know I'm resurrecting this post from the dead, but...

I have a sudden need to do this as well, and discovering that objcopy doesn't work on OSX was a bit of a shock. But I think it's possible to use ld to achieve the same effect:

ld -r input.o -o output.o -alias oldsymbol newsymbol -unexported_symbol oldsymbol

This really just creates an alias for the symbol under a new name and hides the old one.

I haven't had a chance to do much testing yet, but looking at the output file with nm shows it seems to be doing the right thing.

objconv does not currently work for ARM, so this option is not available for iPhone. It should be no problem to use objconv from elf to mach-o for mac osx x86/x64 though. Let me know if you found a solution for ARM

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!