Homework 1 (due 7 Feb)

Background

This homework assignment is designed to reinforce your understanding of the output of the compiler and the symbol resolution performed by the linker.

As we learned in class and in Bryant & O'Hallaron chapter 7 the compiler outputs relocatable object files with the file extension *.o in the Executable and Linkable Format (ELF). To see this output invoke gcc with the -c flag.

gcc -c hw1_a.c

We can see the contents of the symbol table in these relocatable object files with the linux utility readelf

readelf -s hw1_a.o

We also learned that the (aptly named) linker links these relocatable objects together into an executable file.

The Assignment

hw1 is an executable whose output prints your netid to the screen. However, it's doing some things in the background that aren't obvious until we look at the symbol tables.

hw1_a.o

readelf output from hw1_a.o

hw1_b.o

readelf output from hw1_a.o

Your job is to use your knowledge of c, ELF, and linkers to recreate hw1_a.c and hw1_b.c so that their symbol tables match those shown above with the criteria below.

You will get 1 point for compiling without errors using the Makefile provided and 1 point for each matching OBJECT, FUNC, and NOTYPE line. for a total of 20 points. You will loose points for extra lines.

You should also run readelf on hw1. Do you notice any lines where the linker had to disambiguate between symbols? Which one? Why did this happen? Write a quick note and submit to gradescope.

Best of Luck!!

Zip file of stubs to get you started

Submission Instructions