Mac / iPhone 的 objcopy 等效项?

发布于 2024-09-14 01:46:15 字数 275 浏览 5 评论 0原文

我想使用 Mac 上相当于 binutils 的 objcopy --redefine-syms 工具的东西来重命名对象文件 (.o) 内的符号。

我没有找到arm-apple-darwin10-objcopy。我尝试了 MacPorts 的 arm-elf-binutils 端口,还尝试使用 otoolsegedit 进行操作,但没有取得太大成功。

有什么想法吗?

I would like to rename symbols inside object files (.o) with something that would be the Mac equivalent of binutils' objcopy --redefine-syms tool.

I found no arm-apple-darwin10-objcopy. I tried the MacPorts' arm-elf-binutils port and also tried to play a bit with otool and segedit without much success.

Any ideas please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

删除会话 2024-09-21 01:46:15

听起来像是 Agner Fog 的 objconv 的工作。

来自 公告

我现在已经完成了对我之前帖子中提到的目标文件转换器中的 Mach-O 文件的全面支持。您可以使用它来替代缺少的 objcopy 实用程序。

Objconv 可用于以下目的:
在所有 x86 和 x86-64 平台的 Mach-O、ELF、COFF 和 OMF 格式之间转换目标文件和库/存档文件。

更改目标文件中的符号名称、使符号变弱、为符号添加别名。

跨平台(Mac、Linux、BSD、Windows)构建、修改和转换静态库文件(*.a、*.lib)

转储目标文件和可执行文件

反汇编目标文件和可执行文件。非常好的反汇编程序。

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.

隱形的亼 2024-09-21 01:46:15

我知道我正在复活这篇文章,但是......

我也突然需要这样做,并且发现 objcopy 在 OSX 上不起作用有点震惊。但我认为可以使用ld来达到相同的效果:

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

这实际上只是在新名称下为符号创建一个别名并隐藏旧名称。

我还没有机会进行太多测试,但是使用 nm 查看输出文件表明它似乎正在做正确的事情。

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.

梦境 2024-09-21 01:46:15

objconv 目前不适用于 ARM,因此此选项不适用于 iPhone。不过,在 mac osx x86/x64 上使用 objconv 从 elf 到 mach-o 应该没有问题。如果您找到 ARM 的解决方案,请告诉我

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文