The following program demonstrates this.
--- Cut Here ------
/* segflt.c - oh really!! */
int dummy( )
{
return 0;
}
extern inline unsigned int get_cr0()
{ unsigned int val;
__asm__ __volatile__ (
"movl %%cr0,%0" : "=r" (val) );
return val;
}
int j;
int main()
{
dummy();
j = get_cr0();
printf( "\nget_cr0() returned: 0x%08lx\n", j );
} /* main */
--- Cut Here ------
Breakpoint 1, main () at segflt.c:9
(xxgdb) disass main
Dump of assembler code for function main:
0x80004f8 <main>: pushl %ebp
0x80004f9 <main+1>: movl %esp,%ebp
0x80004fb <main+3>: call 0x80004e8 <dummy>
0x8000500 <main+8>: movl %cr0,%eax <-- "SIGSEGV" here
0x8000503 <main+11>: movl %eax,0x8001694
0x8000508 <main+16>: pushl %eax
0x8000509 <main+17>: pushl $0x80005a8
0x800050e <main+22>: call 0x80003a8 <printf>
0x8000513 <main+27>: movl %ebp,%esp
0x8000515 <main+29>: popl %ebp
0x8000516 <main+30>: ret
End of assembler dump.
(xxgdb) displ/x $eip
(xxgdb) displ/x $eax
(xxgdb) next
Program received signal SIGSEGV, Segmentation fault.
main () at segflt.c:9
___________________________________________________________
Howard C. Tyler | email: theurgi@primenet.com
phn: (602)-866-9074 | 1KSPT: 13.96 exCOG 1741
___________________________________________________________