Harvey Mudd CS 105 - Machine-­Level Programming V: Miscellaneous Topics (28 pages)

Previewing pages 1, 2, 3, 26, 27, 28 of 28 page document View the full content.
View Full Document

Machine-­Level Programming V: Miscellaneous Topics



Previewing pages 1, 2, 3, 26, 27, 28 of actual document.

View the full content.
View Full Document
View Full Document

Machine-­Level Programming V: Miscellaneous Topics

68 views

Lecture Notes


Pages:
28
School:
Harvey Mudd College
Course:
Cs 105 - Computer Systems
Computer Systems Documents

Unformatted text preview:

CS 105 Tour of Black Holes of Computing Machine Level Programming V Miscellaneous Topics Topics X86 5a ppt Linux Memory Layout Understanding Pointers Buffer Overflow Floating Point Code FF Stack Linux Memory Layout Stack Upper 2 hex digits of address C0 BF Stack Runtime stack Heap Dynamically allocated storage When call malloc calloc realloc new DLLs 80 7F Heap Dynamically Linked Shared Libraries Library routines e g printf malloc Linked into object code when first executed Data 40 3F 2 08 00 DLLs Heap Data Text Statically allocated data E g arrays strings declared in code Text Executable machine instructions Read only 105 Linux Memory Allocation Initially BF Stack 80 7F Some Heap Linked BF Stack 80 7F BF Stack 80 7F More Heap BF Stack 80 7F Heap Heap 40 3F 08 00 3 40 3F Data Text 08 00 DLLs Data Text 40 3F 08 00 DLLs Data Text 40 3F 08 00 DLLs Heap Data Text 105 Text Stack Example gdb break main gdb run Breakpoint 1 0x804856f in main gdb print esp 3 void 0xbffffc78 Main Address 0x804856f should be read 0x0804856f Initially BF 80 7F 40 3F Stack 4 Address 0xbffffc78 Stack 08 00 Data Text 105 Dynamic Linking Example Linked gdb print malloc 1 text variable no debug info BF 0x8048454 malloc gdb run Program exited normally gdb print malloc 2 void unsigned int 0x40006240 malloc 80 7F Initially Code in text segment that invokes dynamic linker Address 0x8048454 should be read 0x08048454 Final 5 Code in DLL region 40 3F 08 00 Stack DLLs Data Text 105 Memory Allocation Example char big array 1 24 16 MB char huge array 1 28 256 MB int beyond char p1 p2 p3 p4 int useless int p1 p2 p3 p4 6 return 0 main malloc 1 malloc 1 malloc 1 malloc 1 Some print 28 256 MB 8 256 B 28 256 MB 8 256 B statements 105 Example Addresses esp p3 p1 Final malloc p4 p2 beyond big array huge array main useless Initial malloc 7 0xbffffc78 0x500b5008 0x400b4008 0x40006240 0x1904a640 0x1904a538 0x1904a524 0x1804a520 0x0804a510 0x0804856f 0x08048560 0x08048454 BF Stack 80 7F Heap 40 3F DLLs Heap 08 00 Data



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Machine-­Level Programming V: Miscellaneous Topics and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Machine-­Level Programming V: Miscellaneous Topics and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?