






































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This lecture is from Operating System Design and Implementation course. Its key words are: Stack Discipline, Registration, Process Memory Model, Ia32 Stack Organization, Register Saving Conventions, Project 0, Linux Memory Layout, Stack Operation, Procedure Return, Linux Stack Frame, Register Saving Conventions, Mysterious Parts, Data Flow
Typology: Slides
1 / 46
This page cannot be seen from the preview
Don't miss anything!
(^) Lots of registers, registers more orthogonal
(^) Machine begins in 16-bit mode, then 32, finally 64 » You don't have time to write 32⇒64 transition code » If we gave it to you, it would be a^ big^ black box
(^) More registers means more registers to have wrong values
(^) More steps than x86-32, but not more intellectually stimulating
(^) ...which can boot and run your personal OS
(^) Runtime stack (8MB limit by default)
(^) Dynamically allocated storage (^) Managed by malloc() , calloc() , new
(^) Library routines (e.g., printf() , malloc() ) (^) Linked into object code when first executed (^) Windows has “DLLs” (semantic differences)
(^) Statically allocated data (BSS starts all-zero) (^) e.g., arrays & variables declared in code
(^) Text - Executable machine instructions (^) RODATA – Read-only (e.g., “ const ”) (^) String literals Upper 2 hex digits of address Red Hat v. 6. ~1920MB memory limit
Stack Libraries Text Data 08
Stack Libraries Text Data Heap 08
Stack Libraries Text Data Heap Heap 08
Stack Text Data 08
(^) Maybe a register: %ebp (^) Maybe memory: 8(%ebp)
Stack Grows Down Increasing Addresses Stack “Top” Stack “Bottom” Stack Pointer %esp -
Stack Pointer %esp Stack Grows Down Increasing Addresses Stack “Top” Stack “Bottom”
(^) Return address = 0x
%esp %eip %esp %eip 0x804854e 0x 0x 0x10c 0x 0x 0x804854e 0x
0x 0x10c 0x 123 0x call 8048b 804854e: e8 3d 06 00 00 call 8048b90
(^) Multiple instantiations of a single procedure “live” at same time
(^) Arguments (^) Local variables (^) Return pointer (maybe) (^) Weird things (static links, exception handling, …)
(^) From time of call to time of return
yoo(…) {
} who(…) {
} yoo who amI amI amI**
amI
(^) “Argument build”
(^) If don't all fit in registers
(^) Pushed by call instruction
Stack Pointer ( %esp ) Frame Pointer ( %ebp ) Return Addr Saved Registers
Local Variables Argument Build Old %ebp Arguments Caller Frame
**void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; xp = t1; yp = t0; } int zip1 = 15213; int zip2 = 91125; void call_swap() { swap(&zip1, &zip2); } call_swap:
**- • • pushl $zip2 # Global var pushl $zip1 # Global var call swap