JOS实验——Exercise 9

实验九:

堆栈的初始化:

在entry.S中:

    # Clear the frame pointer register (EBP)
    # so that once we get into debugging C code,
    # stack backtraces will be terminated properly.
    movl    $0x0,%ebp            # nuke frame pointer

    # Set the stack pointer
    movl    $(bootstacktop),%esp

    # now to C code
    call    i386_init

其中bootstacktop为0xf0110000,也就是将内核态堆栈的esp设置为0xf0110000,在i386_init中:

void
i386_init(void)
{
f010009d:	55                   	push   %ebp
f010009e:	89 e5                	mov    %esp,%ebp
f01000a0:	83 ec 18             	sub    $0x18,%esp

其中mov %esp, %ebp则初始化了ebp的值。

因此,内核空间的堆栈是从0xf0110000开始向下增长的。


你可能感兴趣的:(c,debugging)