Using objdump for ARM architecture: Disassembling to ARM

有些话、适合烂在心里 提交于 2020-01-12 04:54:27

问题


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.

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


回答1:


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

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 -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.

Hope this can help you.




回答2:


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

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

./configure --enable-targets=all for example.

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 -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]
...



回答3:


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




回答4:


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



来源:https://stackoverflow.com/questions/3859453/using-objdump-for-arm-architecture-disassembling-to-arm

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