This problem is about functions that push some float registers at the beginning, but forget to pop them at the end. The stack pointer is not adjusted as expected, so the function return to an invalid address.
It appears when the following is true:
- the file is compiled with -m68020-60 -O1 -fomit-frame-pointer
- the function uses floats
- the function is complicated enough to have some float registers backed up on the stack
- there is an early return in the function
The problem appears in the following test case:
$ cat bug.c
volatile float g1;
if (g2 >= 0)
for (i = 0; i < 10; ++i)
g1 = g2 + i;
$ gcc -S bug.c -o - -m68020-60 -O2 -fomit-frame-pointer
.type f, @function
We can see that some float registers are backuped at the beginning. Then (g2 >= 0) is checked. If it is the case, the function returns with a simple rts, without restoring the registers, to an invalid address.
This happens in gcc 4.2.2 and gcc-4.2-20080116
The bug is still here in the official 4.2.3
That patch fixes the problem:
4.2.4 is being released, changing milestones to 4.2.5.
Closing 4.2 branch, fixed in 4.3.