Incorrect thumb disassembly/detection

Tom de Vries tdevries@suse.de
Mon Sep 13 19:31:41 GMT 2021


On 9/11/21 12:41 PM, Maximilian Schneider via Gdb wrote:
> Hello,
> 
> I am working on some code for a cortex-M33 and see that the gdb
> disassembly does not match that of objdump, but only when a target is
> connected.
> 
> $ arm-none-eabi-objdump -d bin/usb_cdc.elf | awk -v RS=
> '/^[[:xdigit:]]+ <main>/'
> 00000cb8 <main>:
>      cb8:	b500      	push	{lr}
>      cba:	b085      	sub	sp, #20
>      cbc:	ab03      	add	r3, sp, #12
> [-snip-]
> 
> $ gdb-multiarch bin/usb_cdc.elf 
> GNU gdb (Debian 8.2.1-2+b3) 8.2.1
> [-snip-]
> (gdb) disas main
> Dump of assembler code for function main:
>    0x00000cb8 <+0>:	push	{lr}
>    0x00000cba <+2>:	sub	sp, #20
>    0x00000cbc <+4>:	add	r3, sp, #12
> [-snip-]
> End of assembler dump.
> (gdb) target remote localhost:2331
> Remote debugging using localhost:2331
> 0x00000000 in __isr_vector ()
> (gdb) disas main
> Dump of assembler code for function main:
>    0x00000cb8 <+0>:	bl	0xd6e4 <USB__IsHighSpeedCapable+12>
>    0x00000cbc <+4>:	cbz	r0, 0xcc8 <main+16>
>    0x00000cbe <+6>:	ldrb.w	r1, [sp, #6]
> [-snip-]
> End of assembler dump.
> 
> stepping instructions increments the program counter by 2 indicating
> thumb mode. So i expect the disassembly also to be thumb.
> 
> What is causeing the disasembly to change to arm mode when a target is
> used?
> 

Hi,

It's a bit of a guess at this point, but you could look at
https://sourceware.org/gdb/current/onlinedocs/gdb/ARM.html .  There I
found f.i.:
...
set arm fallback-mode (arm|thumb|auto)

    GDB uses the symbol table, when available, to determine whether
instructions are ARM or Thumb. This command controls GDB’s default
behavior when the symbol table is not available. The default is ‘auto’,
which causes GDB to use the current execution mode (from the T bit in
the CPSR register).
...
and the behaviour of auto could explain why you're seeing different results.

Thanks
- Tom

> Best Regards!
> 


More information about the Gdb mailing list