Mcount should not clobber any registers. diff --git a/sys/cpu/i386/include/profile.h b/sys/cpu/i386/include/profile.h index dcb2689..c3c6280 100644 --- a/sys/cpu/i386/include/profile.h +++ b/sys/cpu/i386/include/profile.h @@ -92,6 +92,9 @@ void \ mcount(void) \ { \ + register int c asm("ecx"); \ + register int d asm("edx"); \ + register int a asm("eax"); \ uintfptr_t selfpc, frompc; \ /* \ * Find the return address for mcount, \ @@ -99,6 +102,9 @@ mcount(void) \ * \ * selfpc = pc pushed by call to mcount \ */ \ + asm("push %%ecx" : : "r" (c) : "memory"); \ + asm("push %%edx" : : "r" (d): "memory"); \ + asm("push %%eax" : : "r" (a) : "memory"); \ asm("movl 4(%%ebp),%0" : "=r" (selfpc)); \ /* \ * frompc = pc pushed by call to mcount's caller. \ @@ -109,6 +115,9 @@ mcount(void) \ asm("movl (%%ebp),%0" : "=r" (frompc)); \ frompc = ((uintfptr_t *)frompc)[1]; \ _mcount(frompc, selfpc); \ + asm volatile ("pop %%eax" : "=r" (a) : ); \ + asm volatile ("pop %%edx" : "=r" (d) : ); \ + asm volatile ("pop %%ecx" : "=r" (c) : ); \ } typedef unsigned int uintfptr_t;