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
Using objdump for ARM architecture: Disassembling to ARM
提问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
回答by soulseekah
Compile binutils
with 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=all
for example.
./configure --enable-targets=all
例如。
Pick your targets, make and use the new objdump
binary that is your-target-aware. See the binutils/README
file 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
. 希望这可以帮助