gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > OBJDUMP Arm disassembly contiains garbage instructions

#168629 - Dwedit - Tue May 12, 2009 3:17 am

I'm trying to use objdump to disassemble an ARM binary file.
For some reason, the disassembler does some nasty stuff like this:
Code:

 30028a0:   e1a03c45    asr   r3, r5, #24
 30028a4:   e2588c09    subs   r8, r8, #2304   ; 0x900
 30028a8:   0001         lsls   r1, r0, #0
 30028aa:   f10054d9    undefined instruction 0xf10054d9

It's marking part of a 32-bit instruction as a 16-bit instruction, and that's throwing off the disassembly into unaligned territory. How do I stop objdump from doing that?


EDIT:
Using an older version of objdump (GNU objdump 2.17 from 2005) works fine.
The version I was using (GNU objdump (GNU Binutils) 2.19.1) included with the new devkitpro is broken!
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#168641 - Tyler24 - Tue May 12, 2009 8:36 pm

Odd... its working for me...

arm-eabi-objdump -D file.obj produces
Code:
drawsquare.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <drawsquare>:
   0:   e12fff1e    bx   lr
   4:   e1a00000    nop         (mov r0,r0)
   8:   e1a00000    nop         (mov r0,r0)
   c:   e1a00000    nop         (mov r0,r0)

Disassembly of section .ARM.attributes:

00000000 <.ARM.attributes>:
   0:   00001341    andeq   r1, r0, r1, asr #6
   4:   61656100    cmnvs   r5, r0, lsl #2
   8:   01006962    tsteq   r0, r2, ror #18
   c:   00000009    andeq   r0, r0, r9
  10:   01080206    tsteq   r8, r6, lsl #4


What parameters are you passing to objdump?

#168644 - Dwedit - Wed May 13, 2009 3:55 am

It's choking on the "ldrplb r0, [r9], #1" instruction, treating the first 16 bits as a THUMB instruction.

I created a binary file containing that instruction, and disassembled it using the options -D -b binary --architecture=arm, and it disassembled it with no problem. But it consistently screws up when I give it my ELF file. The ELF file I'm disassembling has a mixture of ARM and THUMB code in it. Some symbols are ARM symbols and some are THUMB. But the mistaken instruction doesn't have any symbols pointing there.

The paramaters I'm passing in are just -D filename.elf, and an output redirection to a .s file. I tried playing around with the --architecture=arm switch, that did nothing. I see there is a "force thumb" option, but no corresponding "Force ARM" option.

Should I go upload my ELF file somewhere?
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."