3

I'm getting following error for the disassembling of the object with below command. Object file was generated for MIPS platform.

$objdump -D -m MIPS myobjfile.o

Error:

objdump: Can't use supplied machine MIPS

The snippet I'm attaching for reference from objdump.c

  const bfd_arch_info_type *inf = bfd_scan_arch (machine);

  if (inf == NULL)
      fatal (_("can't use supplied machine %s"), machine);

Can you please help me to get correct assembly code?

Ramesh K
  • 77
  • 1
  • 6
  • 1
    Did you try `objdump -i` to see the list of available architectures? Do you even need to specify `-m MIPS` since `.o` is already a compiled binary? Can it figure out the architecture from the object file? – e0k Feb 19 '16 at 06:05
  • `objdump` and the rest of GNU binutils have compile-time options to choose which architectures are supported. If you're running this on a machine which is not MIPS, it's quite possible that MIPS support wasn't included. In that case, you'll have to download or compile a new set of binutils binaries which does. – Nate Eldredge Feb 19 '16 at 06:10

3 Answers3

4

Way late on this, but this solved my problem which is the same as yours but for ARM64(aarch64).

If you're building from source you can enable all target architectures by passing the --enable-targets=all to ./configure:

git clone git://sourceware.org/git/binutils-gdb.git 
cd binutils-gdb
./configure --enable-targets=all
make

This enables objdump to work with all architectures, including MIPS

This is from @soulseekah post here: Using objdump for ARM architecture: Disassembling to ARM

ste11ar
  • 56
  • 5
3

You should try mips-linux-gnu-objdump. I'm using it as part of binutils-mips-linux-gnu package on my ubuntu 16.04 TLS.

You can download it using apt-get:

$sudo apt-get install binutils-mips-linux-gnu

Then try running:

$mips-linux-gnu-objdump -b binary -m mips -D myobjfile.o

The -b binary stands for binary file format and it's optional.

You should visit https://linux.die.net/man/1/x86_64-linux-gnu-objdump for any further information.

Shlomiza
  • 31
  • 3
0

Try using capital m. $objdump -D -M MIPS myobjfile.o

[-M options|--disassembler-options=options]

Gobbas
  • 1
  • 5