Homework 1: The ELF format
This homework is meant to get you familiarized with the concept of symbols and how they relate to compiling and linking executables.
We covered using git in the week 1 video and discussion section, but if you’re still not that familiar with it, this assignment is a second chance to get up to speed. Remember: git gives you warnings and errors for good reason, if it complains at the command line when you run a command, don’t just assume it’s completed correctly!
Now that you have the skeleton code, you can start coding. You should commit early and often, and push to your remote repository whenever is convenient to back up your work!
This assignment was created in an Ubuntu 18.04 based environment. The
skeleton code comes with a
devcontainer setup script so that running
it in a remote container through Visual Studio Code will put you in the
same environment. This assignment is simple enough that any Linux
environment with an up to date
gcc should be sufficient, including
systems1.cs.uic.edu. If you aren’t/can’t/don’t want to complete this
assignment using vscode remote containers, feel free to complete this on
a lab machine, a local Linux VM, or elsewhere.
The Programming Part!
This part will give you a quick introduction to using
readelf to better
understand the linking process.
In this assignment, you must fill
hw1.c with code which will:
- cause your UIC netID (and nothing else) to be printed on the first line of output when the program is run.
gcc -c -Wall hw1.cand
gcc -Wall -o hw1 *.cto issue zero warnings (and zero errors).
- cause Type, Bind, and Ndx of each Symbol to be the same as in the
example below. E.g.
importantmust have Type
readelf -sW hw1.o on the solution results in:
As a further hint, here’s the mapping between the Section Index and the Section Names:
Section Headers: [Nr] Name [ 0] [ 1] .text [ 2] .rela.text [ 3] .data [ 4] .bss [ 5] .rodata [ 6] .data.rel.local [ 7] .rela.data.rel.local [ 8] .data.rel [ 9] .rela.data.rel  .comment  .note.GNU-stack  .eh_frame  .rela.eh_frame  .symtab  .strtab  .shstrtab
- The four digit numbers do not need to made identical, but you do need to make them show up. Keep experimenting with different variable types until you find how to create variables with periods and numbers on them.
- Order for the symbols does not matter. Take a close look at Chapter 7 and think about what properties of a variable put it in a different section, or would give it a different Binding or Type. Everything you need to know to solve this puzzle is in the book.
There is a very bare bones skeleton and a Makefile provided for this assignment. The skeleton file is worth two points because it compiles with no warnings and no errors.
Grading will be done automatically using Gradescope. Submitting to GitHub is not sufficient - your code must be submitted to Gradescope. If you have issues with the autograder, please contact us via Piazza ASAP. Technical issues with submitting your assignment is not an acceptable excuse for submitting the assignment improperly or late.
This assignment is due Fri, 11 Sep 2020 17:00:00 -0500. See the syllabus for the late turnin policy. This assignment is worth just as much as every other homework, but is easier than all the rest (in our opinion) so getting as much credit on it as possible is important!
Chapter 7 in the book