#18882 - niallz - Wed Apr 07, 2004 7:15 pm
Hi,
I'm just doing some work here, and I've noticed that GCC uses r7 (in thumb mode) when entering and exiting a function for saving the stack pointer. Does anyone know why it does this?
Thanks
Niall
#18888 - poslundc - Wed Apr 07, 2004 7:52 pm
GCC is most likely using r7 as a frame pointer. According to the ARM procedure call standards, any of r4 to r7 can be used as a frame pointer when in Thumb mode. Frame pointers aren't really a necessity, though, so I can't say for certain why it's implementing it.
And Lupin, you are incorrect.
Edit: I am more-or-less saying the same thing that Jeff is... frame pointers are most useful in variadic routines, but I'm not certain why GCC would generate them for non-variadic routines.
Dan.
#18908 - torne - Thu Apr 08, 2004 12:42 am
It uses R7 as the frame pointer in Thumb mode, yes. The reason it generates one for non-variadic functions is because you have not specified -fomit-frame-pointer. Debugging code without a frame pointer can be more difficult on some architectures; I've not used gdb on ARM so no idea if this is the case.