Lecture 7 Linking - Todays Big Adventure - How to name and...

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

View Full Document Right Arrow Icon
Today’s Big Adventure - How to name and refer to things that don’t exist yet - How to merge separate name spaces into a cohesive whole Readings - a.out elf man pages, ELF standard - Run “ nm ” or “ objdump ” on a few .o and a.out ±les. 1/35
Background image of page 1

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

View Full DocumentRight Arrow Icon
Linking as our frst naming system Naming is a very deep theme that comes up everywhere Naming system: maps names to values Examples: - Linking: Where is printf ? How to refer to it? How to deal with synonyms? What if it doesn’t exist? - Virtual memory address (name) resolved to physical address (value) using page table - File systems: translating ±le and directory names to disk locations, organizing names so you can navigate, . .. - www.stanford.edu resolved 171.67.216.17 using DNS - IP addresses resolved to Ethernet addresses with ARP - Street names: translating (elk, pine, . ..) vs (1st, 2nd, . ..) to actual location 2/35
Background image of page 2
Perspectives on memory contents Programming language view: x += 1 ; add $1 , %eax - Instructions : Specify operations to perform - Variables : Operands that can change over time - Constants : Operands that never change Hardware view: - executable : code, usually read-only - read only : constants (maybe one copy for all processes) - read/write : variables (each process needs own copy) Need addresses to use data: - Addresses locate things. Must update them when you move - Examples: linkers, garbage collectors, changing apartment Binding time: When is a value determined/computed? - Early to late: Compile time, Link time, Load time, Runtime 3/35
Background image of page 3

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

View Full DocumentRight Arrow Icon
How is a process specifed? Executable fle: the linker/OS interFace. - What is code? What is data? - Where should they live? Linker builds executables From object fles: 4/35
Background image of page 4
How is a program executed? On Unix systems, read by “loader” - Reads all code/data segs into buffer cache; Maps code (read only) and initialized data (r/w) into addr space - Or. ..fakes process state to look like paged out Lots of optimizations happen in practice: - Zero-initialized data does not need to be read in. - Demand load: wait until code used before get from disk - Copies of same program running? Share code - Multiple programs use same routines: share code (harder) 5/35
Background image of page 5

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

View Full DocumentRight Arrow Icon
What does a process look like? (Unix) Process address space divided into “segments” - text (code), data, heap (dynamic data), and stack Stack Code Read-only data Initialized data Uninitialized data Heap Kernel regions mmapped - Why? (1) different allocation patterns; (2) separate code/data 6/35
Background image of page 6
Who builds what? Heap: allocated and laid out at runtime by malloc - Compiler, linker not involved other than saying where it can start - Namespace constructed dynamically and managed by programmer (names stored in pointers, and organized using data structures) Stack: alloc at runtime (proc call), layout by compiler - Names are relative off of stack (or frame) pointer - Managed by compiler (alloc on proc entry, free on exit) - Linker not involved because name space entirely local:
Background image of page 7

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

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

This note was uploaded on 03/13/2010 for the course CS 02523 taught by Professor Davidmieres during the Winter '10 term at A.T. Still University.

Page1 / 35

Lecture 7 Linking - Todays Big Adventure - How to name and...

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

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