{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture13-linking-part1

Lecture13-linking-part1 - Announcements Project 3 due Oct...

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

View Full Document Right Arrow Icon
1 CS 3214 Computer Systems Godmar Back Lecture 13 Announcements Project 3 due Oct 14 Exercise 5 coming out today CS 3214 Fall 2011 2 10/17/2011 Some of the following slides are taken with permission from Complete Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective (CS:APP) Randal E. Bryant and David R. O'Hallaron http://csapp.cs.cmu.edu/public/lectures.html LINKING AND LOADING Part 1 10/17/2011 CS 3214 Fall 2011 3 Topics Static linking Object files Static libraries Loading Dynamic linking of shared libraries Linking is a mundane topic Full of quirks and seemingly arbitrary rules But worth learning, IMO Essential skill for any practicing C programmer Necessary skill for productive practice in mixed-language and inter-language environments 10/17/2011 CS 3214 Fall 2011 4 Compiling and Linking Compiler driver coordinates all steps in the translation and linking process. Typically included with each compilation system (e.g., gcc ) Invokes preprocessor ( cpp ), compiler ( cc1 ), assembler ( as ), and linker ( ld ). Passes command line arguments to appropriate phases Example: create executable p from m.c and a.c : bass> gcc -O2 -v -o p m.c a.c cpp [args] m.c /tmp/cca07630.i cc1 /tmp/cca07630.i m.c -O2 [args] -o /tmp/cca07630.s as [args] -o /tmp/cca076301.o /tmp/cca07630.s <similar process for a.c> ld -o p [system obj files] /tmp/cca076301.o /tmp/cca076302.o bass> cpp has been integrated into cc1 10/17/2011 5 CS 3214 Fall 2011 The Big Picture Program Code .c/.cc Source File 1 Assembly Code .s File 1 Program Code .c/.cc Source File 2 Assembly Code .s File 2 .h Header File 1 .h Header File 2 .h Header File 3 Preprocessor Compiler Compile Time 10/17/2011 CS 3214 Fall 2011 6 Object Code .o File 1 Object Code .o File 2 Executable Program1 Process1 Physical RAM (physically addressed) Assembler Linker Loader MMU Run Time Load Time Link Time Executable Program2 Process2 Process3
Image of page 1

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

View Full Document Right Arrow Icon