Wednesday, August 14, 2013

"blx" and the .thumb_func gas directive

Encountered a major hard fault inside main().  Specifically the stm32_uart_init() functions call of tclib_memset().

under gdb, "layout asm" displayed the dis-assembly of the code and showed that instead of generating a "bl" instruction, the compiler was generating "blx" which implies a switch back to arm - which CANNOT happen on a cortex-m3

I had
-mthumb
-mno-thumb-interwork
-mcpu=cortex-m3

all set in CFLAGS.

Searching the net revealed the cause of it - a compiler "bug":
http://knowledgebase.nxp.com/showthread.php?t=674
tied to C functions calling assembly routines on a thumb ISA

The solution was to place the ".thumb_func" directive before any labels in the assembly source. This worked and got me passed this error ... but there are others ...


btw ".syntax unified" is needed to assemble my tclib.S asm source file with gcc

No comments:

Post a Comment