Steve
Steve

Reputation: 221

Using objdump for ARM architecture: Disassembling to ARM

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?

Upvotes: 22

Views: 104842

Answers (6)

tedy58
tedy58

Reputation: 99

I am using Debian 12. So I install arm-trusted-firmware-tools which is Debian's arm disassembly tool:

sudo apt install arm-trusted-firmware-tools

After that I use similar command as above (qiuhan1989), and save the file as .asm one

arm-none-eabi-objdump -D -b binary -marm binary.elf > binary.elf.asm

Upvotes: 0

aremmell
aremmell

Reputation: 1362

I had this issue on macOS (arm64). For some reason, configure had located objdump from the Xcode SDK, and I'm not cross-compiling, so Xcode must contain the Intel binaries as well.

All I had to do was brew install binutils – problem solved.

Upvotes: 0

vbenara
vbenara

Reputation: 111

Before disassembling the binary, check the filetype via "file", for example:

file dnslookup.o

dnslookup.o: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped

So now we know it is an ARM object or ELF file.

To disassemble arm object file use arm-linux-gnueabi-objdump. In Ubuntu, "arm-linux-gnueabi-objdump" is the default disassembler for ARM binaries - no compilation is needed.

To install it, just do:

sudo apt-get install binutils-arm-linux-gnueabi

There are also other binaries inside this package that can further analyze the ARM binaries for you.

Upvotes: 9

qiuhan1989
qiuhan1989

Reputation: 1663

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.

Upvotes: 23

soulseekah
soulseekah

Reputation: 9162

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

Upvotes: 7

Jonathan
Jonathan

Reputation: 13624

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

Upvotes: 4

Related Questions