types - 5/12/10 1 Announcements Reading Assignments to date...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 5/12/10 1 Announcements Reading Assignments to date To be completed this week Franek Ch 3-6 TICPP Ch 1, TICPP V2 Ch 1,2 (part 1) Franek Ch 7, 8(review), TICPP Ch 11 TICPP Ch 8 TICPP 16, TICPP V2 Part2 Chpt 7 (skim ch2-3) TICPP 14, 15 1 Processes A process is an executable program that has been copied into memory and then handed to Linux (the OS) to run (give it a chance to use the CPU). Linux assigns a process ID (PID) to the process The compilation process (including linking) creates the executable program 2 SF1 . . . compilaon . . . Lib obj 2 Lib obj 1 . . . SF2 SF3 OF 1 OF 2 OF 3 linking (relocaon + linking) load fle (1) preprocess (*.ii) (2) compile (*.s) (3) assemble (*.o) (4) link Make executable: o exename Or stac lib libX.a (5) link dynamic libs (if any) and load into memory SF Source File (le.c/cpp) OF Object File (le.o) Lib obj Library File (libX.a) Dyn. Linked library (libX.so) Object File Format (Review) The format of an object file in Linux is called the UNIX ELF format (the E xecuteable and L inking F ormat) Format: 4-byte magic number followed by a series of sections objdump and readelf Tools that provide you with information about an executable object file g++ o main main.cpp helper.cpp file main main: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped objdump d j .data main objdump d j .rodata main objdump d j .bss main objdump d j .text main 3 \177ELF .text .rodata .data .bss .symtab .rel.text .rel.data .debug .line Secon header table Executable Object File Format ELF format, with potentially multiple copies of the sections 4 sections Loading the Executable Object File into Memory 5 (created by malloc/new) segments User stack Memory area that holds a LIFO data structure for the activation records of each function call Per-function storage for Local variables and parameters Temporary compiler storage Return address (addr of instruction in the caller that immediately follows the call to this function) Storage class: auto Compiler sets up layout/size Created on a call instruction Destroyed on a return 5/12/10 2 7 Activation Records (Stack Frames) i j param1 param2 return address void foo(int param1, int param2) { int i, j; } Storage for automatic variables Locals, parameters, compiler temporaries Return address- instruction to jump to upon completion of the current method instruction address in caller *** The order of the entries depends on the compiler int main() { int k = 2, p=7; foo(k,p); p = } In this example: Caller is main & Callee is foo k p return address foos frame mains frame 8 Activation Records (Stack Frames) i j param1 param2 return address void foo(int param1, int param2) { int i, j; } Storage for automatic variables...
View Full Document

Page1 / 15

types - 5/12/10 1 Announcements Reading Assignments to date...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online