Linux 将 objdump 用于 ARM 架构:反汇编为 ARM

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3859453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 23:41:42  来源:igfitidea点击:

Using objdump for ARM architecture: Disassembling to ARM

linuxarmdisassemblyobjdump

提问by Steve

I have an object file and am trying to disassemble it. When I use:

我有一个目标文件,正在尝试反汇编它。当我使用:

objdump -d example.o

I get an assembly in code in the file format of elf64-x86-64.

我得到一个文件格式为elf64-x86-64.

I am trying to disassemble this into ARM, how do I go about doing this?

我想把它反汇编成 ARM,我该怎么做?

回答by Jonathan

Install the ELDKand use arm-linux-objdump. You're trying to disassemble ARM instructions using a program that only knows x86.

安装ELDK并使用 arm-linux-objdump。您正在尝试使用只知道 x86 的程序反汇编 ARM 指令。

回答by soulseekah

Compile binutilswith the right target(s) to get binutils objdump binary that knows how to disassemble ARM.

binutils使用正确的目标进行编译以获得知道如何反汇编 ARM 的 binutils objdump 二进制文件。

http://www.gnu.org/software/binutils/

http://www.gnu.org/software/binutils/

./configure --enable-targets=allfor example.

./configure --enable-targets=all例如。

Pick your targets, make and use the new objdumpbinary that is your-target-aware. See the binutils/READMEfile for more information on targeting.

选择你的目标,制作并使用objdump你的目标感知的新二进制文件。有关binutils/README定位的更多信息,请参阅该文件。

objdump -D t3c # stock binary
objdump: t3c: File format not recognized

vs.

对比

./../../binutils-2.22/binutils/objdump -D t3c # latest compiled from source with all targets
In archive t3c:

t3c:arm:     file format mach-o-le


Disassembly of section .text:

00002d94 <start>:
    2d94:   e59d0000    ldr r0, [sp]
...

回答by qiuhan1989

If you want to do disassemble of ARM code, you'd better have an ARM tool chain, this is what I got:

如果你想做ARM代码的反汇编,你最好有一个ARM工具链,这是我得到的:

http://bb.osmocom.org/trac/wiki/toolchain

http://bb.osmocom.org/trac/wiki/toolchain

After you have this, you can use arm-elf-objdump instead of objdump. The command I used is

有了这个之后,你就可以使用 arm-elf-objdump 而不是 objdump。我使用的命令是

arm-elf-objdump -D -b binary -marm binaryfile.dat

If you look the manpage, you will find "-b" is followed by the file type. Sorry I don't know how to tell -b you want to analyze a .o file. "-marm" will tell the cpu is ARM.

如果您查看联机帮助页,您会发现“-b”后跟文件类型。抱歉,我不知道如何告诉 -b 您要分析 .o 文件。“-marm”会告诉 CPU 是 ARM。

Hope this can help you.

希望这可以帮到你。

回答by V.ben

You have to cross compile the file for arm first using arm-linux-gnueabi-gcc. You are using native objdump. To disassemble arm object file use arm-linux-gnueabi-objdump. Hope this helps

您必须首先使用arm-linux-gnueabi-gcc. 您正在使用本机 objdump。要反汇编 arm 目标文件,请使用 arm-linux-gnueabi-objdump. 希望这可以帮助