Dears I also have some illegal instrction while running my application on target. i am using the 4.3.2 compiler version with the following options -msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv4t -mtune=arm920t -O0 but when I run my simple application I have the illegal error. my application is really easy. int main() { unsigned short __crcBlockSize = 16384; size_t __sectionSize = 392; unsigned int res = 0; res = (__sectionSize+ __crcBlockSize+3) / (__crcBlockSize+4); printf("res : %d\n",res); return 0; } if I do the same operation with values instead of variable then it works fine of course.
Illegal instruction with int divisions
note that this application compiled with -O0 does not work but it runs fine with -Os, -O1 or even -O2... so really strange
Where is size_t typedef'ed. Do you have a bunch of include files before this? Is it the correct printf parameter? (%d?, integer versus float?)
size_t was correctly defined in stddef.h. but after some investigation I found that the -march=armv4t option was not passed to the linker and cause that issue. as a consequence my exe was compiled for ARMV10. I found this with the readelf application. after adding the correct architecture on my linker command line everything is working fine. I am still surprise that the target does not complain that the exe has not been compiled for the correct target... thx for your help.