On Nov 9, 2011, at 9:39 AM, Don Quixote de la Mancha wrote:
> GDB's disassembly is correct for the Thumb code, but when I am in ARM
> mode, it disassembles the ARM instructions as if each one were a pair
> of completely nonsensical Thumb instructions. Is there some way I can
> tell GDB to switch to ARM disassembly, then upon returning to Thumb
> code, use the Thumb disassembler?
gdb chooses ARM or Thumb on a per-function basis, using information provided in
the assembly file.
If you mark a function as .thumb_func, then gdb will disassemble it as if it
were Thumb. If it is not marked, gdb will disassemble it as if it were ARM. The
linker does the same: if the function is marked .thumb_func, then the linker
and loader will set the low bit of that function pointer so calls to it enter
in Thumb mode.
You can force gdb to disassemble at an address using ARM or Thumb:
% x/10wi address // disassemble 10 ARM instructions at address
% x/10hi address // disassemble 10 Thumb instructions at address
> .globl _IntNoArgs
> .align 2
> .code 16
> .thumb_func _IntNoArgs
>
> _IntNoArgs:
> @ int IntNoArgs( void );
> .loc 1 __LINE__ 0
>
> adr r0, Larm1 @ Larm1 is a PC-relative address. r0's low bit
> will be cleared
> bx r0 @ Switch to ARM mode then branch to Larm1.
> That's the next instruction
>
> .align 4
> .code 32
> Larm1:
> stmfd sp!, { r7, lr }
>
> mov r0, #42
>
> ldmfd sp!, { r7, lr }
> bx lr
You're doing too much work here. iOS never used ARM CPUs with ARMv4T's limited
Thumb support, so there's no need to do interworking the hard way. Write each
function using whichever instruction set you want, mark your Thumb entrypoints
with .thumb_func, and use `bx` or `blx` for every function call and return. The
linker and loader will do the rest.
--
Greg Parker [email protected] Runtime Wrangler
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]