Hi All,

 

I am using a Gumstix Overo with the Ubuntu 10.04 LTS armel distribution and this is working well mostly. I have come across a peculiar issue with the native GCC compiler which works find to build the linux kernel and many other projects but there is one problem with it.

 

If I do something like this…

 

float f;

unsigned char *p;

 

f = *((float *)p);

 

this will generate code that causes an ILLEGAL INSTRUCTION runtime signal to be thrown at the process. Further debugging has shown that if the pointer p is word aligned then there is no issue, but if p is not word aligned then the ILLEGAL INSTRUCTION will be fired at the program (which if not caught will terminate the code).

 

Does anyone know if there is a gcc compiler flag I can get to fix this issue. I did not have this issue with the previous version of GCC on my overo with the Ubuntu 9.04 build. But it seems to have cropped up with the upgrade.  I had noticed this in the past in code that used the following gcc flags, -mfpu=neon -mfloat-abi=softfp -ffast-math, but if I removed these flags the problem went away. Now with the new compiler this problem sticks around with or without these flags.

 

To assist anyone with further debugging on this issue, below is a small test.c example that will exhibit the issue.

 

#include <stdio.h>

#include <signal.h>

 

#define R4(p)       (*((float  *)(p)))

 

void sig_trap(int signo) {

        printf("Caught Signal - %d\n", signo);

        return;

} /* sig_trap */

 

void register_signal_handlers() {

        signal(SIGILL, sig_trap);

}

 

int main(int argc, char **argv) {

        int i;

        unsigned char buf[64];

 

        printf("Starting main\n");

        register_signal_handlers();

 

 

        for (i = 0; i > 64; i++)

                buf[i] = i;

 

        for (i = 0; i < 16; i++)

                printf("%d, value of i = %f\n", i, R4(&buf[i]));

 

        printf("Completed Test\n");

}

 

Example output!

 

root@n2:~# ./test

Starting main

0, value of i = 0.000000

Caught Signal - 4

1, value of i = 0.000117

Caught Signal - 4

2, value of i = 0.620234

Caught Signal - 4

3, value of i = 1.780059

4, value of i = -0.398863

Caught Signal - 4

5, value of i = -1.699432

Caught Signal - 4

6, value of i = -1.962429

Caught Signal - 4

7, value of i = -1.995304

8, value of i = 2.019390

Caught Signal - 4

9, value of i = 2.002424

Caught Signal - 4

10, value of i = 2.000303

Caught Signal - 4

11, value of i = 2.000038

12, value of i = 2.029823

Caught Signal - 4

13, value of i = 2.003728

Caught Signal - 4

14, value of i = 2.000466

Caught Signal - 4

15, value of i = 2.000058

Completed Test

 

Regards,

 

Paul