Re: switch_to()/doesnt %esp get replaced with %ebp on ret

From: Jamie Lokier (lk@tantalophile.demon.co.uk)
Date: Mon Mar 19 2001 - 09:04:25 EST


That's not nice code from the compiler (suboptimal), but it'll work.
leal -24(%ebp),%esp is perfectly ok in the epilogue of a function.
You're right that %esp is lost -- in this case, %ebp has effectively the
same information.

Think like this: a perfectly normal function (without switch_to) can
have this:

f: pushl %ebp
   movl %esp,%ebp
   pushl %ebx
   ... do stuff, decrement %esp a lot to call functions etc. etc. ...
   movl -4(%ebp),%esp
   popl %ebx
   popl %ebp
   ret

Parity Error wrote:
> in schedule(), switch_to() macro changes esp to
> the new process's stack. But, on exit frm schedule,
> how come it does not get overwritten with ebp-24,
> as the dissasembled code shows. The code was compiled
> without the -fomit-frame-pointer.
>
> pushl 508(%ecx)
> jmp __switch_to
> 1: popl %ebp
> popl %edi
> popl %esi
>
> jmp .L1180
>
> .L1180:
> leal -24(%ebp),%esp
> popl %ebx
> popl %esi
> popl %edi
> movl %ebp,%esp
> popl %ebp
> ret
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 23 2001 - 21:00:12 EST