MIT 6.828 HW1 Boot xv6
Notes of MIT 6.828 HW1.
Boot xv6
Clone the repository and build xv6.
Finding and breaking at an address
We can find the address of _start
at 0x0010000c
.
1 | ❯ nm kernel | grep _start |
Set a break point there and run into it in gdb.
1 | pwndbg> target remote localhost:26000 |
Exercise: What is on the stack?
At the above breakpoint, inspect the register valuea and the stack contents.
1 | pwndbg> info reg |
- Where in bootasm.S is the stack pointer initialized?
- At line 65,
movl $start, %esp
,esp
was set to0x7c00
.
- At line 65,
- Single step through the call to bootmain; what is on the stack now?
- The saved
eip
which points to0x7c4d
, otherwise, the return address ofbootmain()
.
- The saved
- What do the first assembly instructions of bootmain do to the stack?
- They save the old
ebp
and make a stack frame by setebp
to the value ofesp
, then save the oldedi
,esi
,ebx
, and subtractesp
by 0x10.
- They save the old
- Look for the call that changes eip to 0x10000c. What does that call do to the stack?
- The call is at
0x7d91
,call *0x10018
. This call pushes currenteip
on the stack.
- The call is at
So now we can figure out the non-zero value on the stack at the above breakpoint. The 0x7c4d
at 0x7bfc
and 0x7d97
at 0x7bdc
are both old eip
saved by call.
1 | 0x7c00: 0x8ec031fa not the stack |