mis-handling of arm semihosting in libgloss/arm/crt0.S

Can Finner can.finner@gmail.com
Thu Jun 16 15:14:00 GMT 2011

> Anyway, you are correct, the wrong software interrupt instruction is being
> used when crt0.S is built for ARMv[67]-M architectures.  Please could you
> try out the attached patch which I think should fix things, and let me know
> how you get on ?
Thanks for your help.
As for the question we are talking about, I think it's more complicated.
Since we have macros in swi.h like

#define AngelSWI_ARM 			0x123456
#ifdef __thumb__
#define AngelSWI 			0xAB
#define AngelSWI 			AngelSWI_ARM

So, your patch
-#if defined(__thumb2__)
-	bkpt	AngelSWI
-	/*  We are always in ARM mode for startup */
-	AngelSWIAsm	AngelSWI_ARM
+	AngelSWIAsm	AngelSWI
 	ldr	r0, .LC0	/*  point at values read */

will use 0xAB for all thumb state, which is only correct for thumb2
and armv6-m here. Considering thumb state on architecture pre armv6,
as the comment, we are always in ARM mode for startup for these
architectures, and should use 0x123456 for these archs here.

actually found this problem during my work on supporting
armv7-m/armv6-m in libgloss/arm and have already worked out a patch.
Hoping I could pass internal review and send it to newlib list ASAP.
Please help me review it then. :(


More information about the Newlib mailing list