Joel Winarske <joelw@...> schrieb am Wed, 30 Nov 2005
02:14:46 -0800:
>> Any general hints about the cause of such an exception, except the
>> PC somehow gone to the woods, are appreciated...
>
> I seem to recall seeing when porting some AVR code. It was calling a
> function via pointer that was defined as NULL.
>
> I'm curious what else triggers this.
A simple stack corruption.
void d(void);
void func(void)
{
int a[2];
d(); /* forces pushing of LR */
a[2] = 0;
}
compile with:
arm-thumb-elf-gcc -fomit-frame-pointer -S -mthumb
you get:
.code 16
.file "t.c"
.text
.align 2
.global f
.code 16
.thumb_func
.type f, %function
f:
push {lr}
sub sp, sp, #8
bl d
mov r2, sp
mov r3, #0
str r3, [r2, #8]
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
add sp, sp, #8
@ sp needed for prologue
pop {pc}
.size f, .-f
.ident "GCC: (GNU) 3.4.4"
Normaly not that obvious coded :-)
--
42Bastian Schick