I'm using arm-linux-gcc 4.0.2 from DJWillis' Open2x toolchain to compile my GP2X apps, and I noticed that when I compile my apps with either -O3 or -pg (the gprof option, to generate profiling), everything works fine, but when I compile with both -pg and -O3, I often get a segmentation fault. Same with -O2 or -O1 instead (and obviously not -O0).
Worst is that debugging the resulting binary with gdb reveals that the segmentation fault takes place in function mcount(), which is -pg's profiling function.
So, what's up with that? Did anyone experience that? And I need to be able to profile when I have -O3 enabled, so what can I do?
Edit : I forgot to precise that I also use the following arguments : -static -lSDL -lpthread -lpng -lz -lm
Worst is that debugging the resulting binary with gdb reveals that the segmentation fault takes place in function mcount(), which is -pg's profiling function.
So, what's up with that? Did anyone experience that? And I need to be able to profile when I have -O3 enabled, so what can I do?
Edit : I forgot to precise that I also use the following arguments : -static -lSDL -lpthread -lpng -lz -lm