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,espwas set to0x7c00.
- At line 65,
- Single step through the call to bootmain; what is on the stack now?
- The saved
eipwhich 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
ebpand make a stack frame by setebpto the value ofesp, then save the oldedi,esi,ebx, and subtractespby 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 currenteipon 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 |