Do I need to enable some compiler switches? This simple test program does not work, and gives me some warning messages.
Code:
get_sp.c:3: warning: `signal' attribute directive ignored
get_sp.c:3: warning: `naked' attribute directive ignored
get_sp.c: In function `get_sp':
get_sp.c:16: warning: control reaches end of non-void function
Code:
#include <stdio.h>
unsigned long get_sp(void) __attribute__((signal, naked));
int main(void)
{
printf("ESP = 0x%lx\n", get_sp());
return 0;
}
unsigned long get_sp(void)
{
__asm__ __volatile__("movl %esp, %eax");
__asm__ __volatile__("ret");
}