Overview

In this reading we’ll look at how object files are produced and linked together to form an executable file. This topic will provide some insight into the structure of executable files and will provide the basis for us understanding how programs are loaded into memory and executed.

Required Reading

Sections 7.0 - 7.9, excluding sections 7.6.2-7.6.3 and 7.7.1-7.7.2 (pp. 670-684, 689-690, 695-698) from the course textbook.

Learning Objectives

BASIC Learning Objectives

Each student will be responsible for learning and demonstrating proficiency in the following objectives PRIOR to the class meeting. The reading quiz will test these objectives.

  1. Describe the roles of the preprocessor, compiler, assembler, linker, and loader in the process of generating and running an executable file.
  2. Describe the two main tasks of the linker.
  3. Compare and contrast the three types of object files.
  4. Given a section in an object module, describe what data it contains.
  5. Compare and contrast global symbols, externals, and local symbols as they pertain to the symbol table.
  6. Given some C code and specific symbol, determine whether that symbol is strong or weak.
  7. Describe the two steps used by the linker during relocation.
  8. Explain why some sections in a relocatable object file are not in an executable object file.
  9. Given a runtime memory image segment, indicate which executable object file sections map to that segment after the program is loaded.

ADVANCED Learning Objectives

The following objectives should be mastered by each student DURING and FOLLOWING the class session through active work and practice.

  1. Given C source code identify which symbols will have an entry in the symbol table, and give both the symbol type and the ELF section for each of those symbols.
  2. Given multiple C modules, determine the module to which each symbol will be resolved, indicating when resolution will result in an error.

Pre-class Exercises

These exercises are geared towards mastering the BASIC learning objectives listed above. You are expected to submit them before class and it is highly recommended that you complete them before attempting the reading quiz.

  1. Which program (e.g. compiler or assembler) is responsible for each of the following tasks:

  2. What is the difference between the .data and .bss sections in an object file?

  3. How do global symbols in the symbol table differ from each of the following:

  4. Consider the following C code.

    int x;
    int y = 5;
    
    int addOne(int a) {
        return a+1;
    }

    For each of the following symbols, indicate whether it is a strong or a weak symbol and briefly describe why.