CS374: Programming Language Principles - The Compilation and Linking Processes
Activity Goals
The goals of this activity are:
- To describe the compilation process
- To define an algorithm to resolve linker dependencies using a multi-pass approach
- To define possible outcomes of the compilation process, including assembly code, machine code, and intermediate bytecode
- To describe the role of external libraries in extending the functionality of a programming language and the mechanisms for integrating them
Supplemental Reading
Feel free to visit these resources for supplemental background reading material.
The Activity
Directions
Consider the activity models and answer the questions provided. First reflect on these questions on your own briefly, before discussing and comparing your thoughts with your group. Appoint one member of your group to discuss your findings with the class, and the rest of the group should help that member prepare their response. Answer each question individually from the activity on the Class Activity Questions discussion board. After class, think about the questions in the reflective prompt and respond to those individually in your notebook. Report out on areas of disagreement or items for which you and your group identified alternative approaches. Write down and report out questions you encountered along the way for group discussion.
Model 1: Linker Processes
Questions
- Assume that we compile with
gcc file1.c file2.c
. What does the compiler have to do with the variable x
in file1.c
, since it does not yet know here the variable is declared?
- With what is the variable
x
updated in file1.c
once it can resolve it to int x
in file2.c
?
- What does the assignment in
a()
do to the variable in file2.c
?
- What if there was a variable in
file2.c
called a
?
- Under what circumstances do you think a variable is bound to a global, versus a linker error?
- In the C language, what do you think the
static
keyword does? How can we use this to protect global variables inside externally linked library functions?
Submission
Submit your answers to the questions using the Class Activity Questions discussion board. You may also respond to questions or comments made by others, or ask follow-up questions there. Answer any reflective prompt questions in the Reflective Journal section of your OneNote Classroom personal section.