[前言]拋磚引玉
Exercise9:
Exercise9:
- Something needed to know
- Understand how did kernel perform its stack creation.
- Discussion:
- Determine where the kernel initializes its stack
- At kern/entry.S
- # Set the stack pointer
- movl $(bootstacktop),%esp
- f0100034: bc 00 00 11 f0 mov $0xf0110000,%esp
- Where in memory its stack is located
- as above: 0xf0110000
- How does the kernel reserve space for its stack
- .space KSTKSIZE
- 8*4096 bytes = 8192 stack frames each 4 bytes
- At which "end" of this reserved area is the stack pointer initialized to point to?
- bootstack
- push data from bootstacktop to bootstack (each one put is -4)
Exercise10:
- Something needed to know
- To be familiar with x86 calling convention.
- Each EBP pused into stack
- the base pointer into the stack used by that function:
- Each EIP pushed into stack
- return instruction. : the instruction address to which control will return when the function returns.
- Set breakpoint at test_backtrace
- Examine what happens each time it gets called after the kernel starts
- How many 32-bit words does each recursive nesting level of test_backtrace push on the stack what are those words?
- EIP/ARGS/EBP
- registers waited to be used
- push its value in, before return, just pop out them.
- Recursive Calling Stack
- stack as linked list array
- From current EIP
- Old EIPs by finding EBP+4 pushed by gcc calling convention
- PIC
- Question
- read_eip
- Doesn't work if inlined
- Putting at the end of the file seems to prevent inlining.
Exercise11:
- Something needed to know
- Based on Exercise10
- Pointer usage
- int*p
- (int)p + 1 - 1base
- (int)(p + 1) - 4base
- GitHub Link
Exercise12:
- Something needed to know
- Based on Exercise11
- printf(%.*) usage
- Stab format
- Trace kern/kdebug.c
- GitHub Link:
#
Enjoy OS travel :)
#
#
No comments:
Post a Comment
歡迎正面積極的討論。