objdump 和 ARM 与 Thumb

发布于 2024-12-01 07:51:43 字数 371 浏览 0 评论 0原文

我正在尝试使用 gcc 反汇编为 ARM 构建的对象。不幸的是,objdump 试图猜测代码是否是 ARM 和 Thumb,但结果是错误的:它认为我的代码是 Thumb,而实际上它是 ARM。

我看到 objdump 有一个选项可以强制它将所有指令解释为 Thumb (-Mforce-thumb),但它没有一个选项可以强制 ARM 模式!

对我来说,这似乎是一个非常奇怪的遗漏,它严重妨碍了我完成工作的能力(我使用的是嵌入式设备,我唯一的调试方法就是查看反汇编)。我尝试了各种方法,包括尝试告诉 objdump 使用不支持 Thumb 的 ARM 架构,但似乎没有任何效果。有什么想法吗?

(是的,我知道这些指令确实 ARM...)

I'm trying to disassemble an object built for ARM with gcc. Unfortunately, objdump is trying to guess whether the code is ARM and Thumb, and is getting it wrong: it thinks my code is Thumb when it's actually ARM.

I see that objdump has an option to force it to interpret all instructions as Thumb (-Mforce-thumb), but it doesn't have one to force ARM mode!

This seems like a really weird omission to me, and it's seriously hampering my ability to get work done (I'm on an embedded device and my only means of debugging is to look at the disassembly). I've tried various approaches, including trying to tell objdump to use an ARM architecture that doesn't support Thumb, but nothing seems to work. Any ideas?

(And yes, I know that the instructions really are ARM...)

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

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

发布评论

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

评论(2

梦一生花开无言 2024-12-08 07:51:43

arm-linux-gnueabi-objdump -marm -b binary -D 对我来说很有效。虽然它不保留符号信息,所以它不完全是您正在寻找的内容,但它为您提供了反汇编,这是一个开始。

arm-linux-gnueabi-objdump -marm -b binary -D does the trick for me. It doesn't preserve the symbol information though, so it's not quite what you are looking for, but it gives you the disassemble, which is a start.

荒路情人 2024-12-08 07:51:43

这听起来像是编译器/链接器或 objdump 中的错误。通常,如果符号是 Thumb 或 ARM,则应正确标记它们,并相应地反汇编。

也就是说,您可以尝试以下一些操作:

  1. 将文件解释为纯二进制文件 (-b 二进制 -D) - 这将禁用符号检查并将整个文件反汇编为 ARM。缺点:输出中有大量垃圾,没有好的地址。
  2. 使用IDA Pro。即使它猜测错误,您也可以随时推翻它的决定。而且,这是一个更好的反汇编环境:)

This sounds like a bug in either compiler/linker or objdump. Normally the symbols should be marked properly if they're Thumb or ARM and disassembled accordingly.

That said, there's a few things you can try:

  1. interpret file as plain binary (-b binary -D) - this will disable symbol checking and will disassemble whole file as ARM. Downside: lots of garbage in the output, no nice addresses.
  2. use IDA Pro. Even if it guesses incorrectly, you can always override its decision. Also, it's a much nicer disassembly environment :)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文