21

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?

frogatto
  • 28,539
  • 11
  • 83
  • 129
Steve
  • 211
  • 1
  • 2
  • 3
  • Just to clarify, are you saying you have a x86_64 executable/object file and would like it disassembled as ARM instructions? – dmckee --- ex-moderator kitten Oct 04 '10 at 22:22
  • yes, a professor has me working on a project and what i want to do is disassemble the object file but i guess it is a x86 executable. If i use arm-linux-objdump i should be able to disassemble into ARM right? – Steve Oct 11 '10 at 00:36
  • 2
    For compiling as well as for disassembly, you need to use ARM cross compiler toolchain. – Jagdish Oct 08 '15 at 05:44

5 Answers5

19

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.

qiuhan1989
  • 1,523
  • 2
  • 13
  • 18
  • 5
    Now you can just install it with `sudo apt install gcc-arm-none-eabi`, and disassemble arm binaries with `gcc-arm-none-eabi-objdump -d -marm `. – borizzzzz Feb 03 '20 at 21:45
  • 4
    In my case (Ubuntu 18.04), `gcc-arm-none-eabi-objdump` didn't work, but `arm-none-eabi-objdump` worked. – lonelyjoe Jul 19 '20 at 18:33
7

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]
...
soulseekah
  • 8,770
  • 3
  • 53
  • 58
7

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.

Peter Teoh
  • 6,337
  • 4
  • 42
  • 58
vbenara
  • 81
  • 1
  • 5
4

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

Jonathan
  • 13,354
  • 4
  • 36
  • 32
0

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.

aremmell
  • 1,151
  • 1
  • 10
  • 15