2

I'm attempting to do an object dump of an assembled program for the pi. I have main.o main.s main.elf and main.bin

otool -tV main.o 

This results in

main.o: is not an object file

What am I doing wrong?

  • 1
    Are you sure you have a version of otool compatible with the pi's object format? Quick googling seems to suggest it might be more commonly an osx tool than a linux one. Have you tried the more typical linux / gnu binutils objdump with the -t flag (either on the pi, or on some other host using a cross binutils built for the same arm-linux target as on the pi)? – Chris Stratton Mar 10 '13 at 23:26
  • I'm assembling on a mac. OK so I'm using the arm-aout toolchain provided by macports. It has a arm-aout-objdump, now im getting File format not recognized. I think I'm going about this wrong? Im assembling a kernel.img but shouldn't it work on main.o? – Paul Meier Mar 10 '13 at 23:38
  • Are you writing a linux program or a bare metal one? You will probably want to use the objdump matching the gcc or assembler you are using, since it will need to be able to parse that binary format. Possibly you can do something with the raw binary .bin image if that's what it is, after using objcopy to turn it back into a recognizable format. Oh, and I mis-typed earlier, you want objdump -d. – Chris Stratton Mar 11 '13 at 0:02
  • Also for anyone wanting further information see this post: link – Paul Meier Mar 11 '13 at 0:33
3

Since you are using a cross binutils, try

arm-xxx-xxx-objdump -D --target binary -marm

With the actual name of your appopriate cross objdump.

You may also need to play with -mthumb depending on what instruction set you have targeted - during execution arm and thumb mode can be distinguished, but it's not always possible to tell when just looking at binaries without heuristics or simulation.

Often thumb code is preferred for the internals of a program, but arm code often shows up in interface stubs, still that depends on the build flags that were used (or in your case, instructions manually written).

It's possible there's a comparable way to get the iphone version of otool to parse an arm binary for the pi, at least to an extent.

  • You may also try evaluation version of IDA Pro - it's very powerful and it support ARM ELF binaries (but you'll not be able to save your work). – kolontsov Mar 11 '13 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.