Homework 1: AWS, git, and linking

Accessing your virtual machine

For this class, you will be using a virtual machine hosted by Amazon Web Services. This virtual machine is running Ubuntu 14.04. You have received instructions on how to access this virtual machine via email. Week one’s lab was the best way to get an introduction to using AWS. I encourage you to seek help on Piazza or during office hours ASAP if you can’t get things running properly.

git, class repositories (repos)

The first objective of this homework is to get you familiarized with the versioning system we will be using for homework turn-in, called git. Git is a decentralized revision control system. You will also get a quick introduction to using readelf and dumpobj to elucidate the linking process.

Using your private key, check out the public course repository:

git clone git@git.uicbits.net:cs361-s15/public.git

Once you’ve cloned the public repo, you will have a directory public filled with useful files for all students, like skeleton code.

your personal repository

You can also check out your personal repository:

git clone git@git.uicbits.net:cs361-s15/YOURUSERNAME.git

You will want to copy the skeleton code from the public direcotry to your new YOURUSERNAME directory. If you’ve never used git before, I’d suggest getting up to speed on it: you can learn some of the basics interactively here.

In this example, my username is ckanich-student. When you first clone the repository, it will be empty. Your first task is to copy the hw1 skeleton code to your repository. If you’ve done that correctly, the tree program will print a graphical (ascii art) representation of the directories and files within the current directory:

ubuntu@ip-10-143-165-210:~$ cd ckanich-student
ubuntu@ip-10-143-165-210:~/ckanich-student$ tree
.
└── hw1
    ├── hw1.c
    └── Makefile

1 directory, 2 files

Now, just to test things out, let’s add these files to the repository, commit them, and send the changes to the central server.

ubuntu@ip-10-143-165-210:~/ckanich-student$ git add hw1
ubuntu@ip-10-143-165-210:~/ckanich-student$ git commit -a -m'added hw1 skeleton'
[master e66c87f] added hw1 skeleton
 3 files changed, 77 insertions(+)
 create mode 100644 hw1/Makefile
 create mode 100644 hw1/hw1.c
ubuntu@ip-10-143-165-210:~/ckanich-student$ git push
Counting objects: 7, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 1.13 KiB, done.
Total 6 (delta 0), reused 0 (delta 0)
To git@git.uicbits.net:cs361-s15/ckanich-student.git
   4781aea..e66c87f  master -> master
ubuntu@ip-10-143-165-210:~/ckanich-student$

Remember, if you don’t push, we don’t see it! We will be making copies of the repositories at each deadline (full credit, 10% off, etc), so do not leave this for the last minute. If you submit it one second too late, you’ll be in the next lateness bracket, no exceptions.

Part of this assignment is to learn git; part of this class is to learn how to solve problems you encounter while programming. We have not included instructions on how to add a git tag to a commit. Google, however, is your friend, and can help you learn how to tag your commits.

The Programming Part!

In this assignment, you must fill hw1.c with code which will:

  1. cause your username (and nothing else) to be printed on the first line of output when the program is run.
  2. cause gcc -Wall hw1.c to issue zero warnings (and zero errors, duh).
  3. cause the correct code to be in the current working directory when the grader runs git checkout hw1.
  4. cause the output of readelf -s hw1.o to have identical values in the bolded sections of the output below:

Symbol table ‘.symtab’ contains 18 entries:

Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND  
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS hw1.c
2: 0000000000000000 0 SECTION LOCAL DEFAULT 1  
3: 0000000000000000 0 SECTION LOCAL DEFAULT 3  
4: 0000000000000000 0 SECTION LOCAL DEFAULT 4  
5: 0000000000000000 0 SECTION LOCAL DEFAULT 5  
6: 0000000000000000 0 SECTION LOCAL DEFAULT 7  
7: 0000000000000000 0 SECTION LOCAL DEFAULT 8  
8: 0000000000000000 0 SECTION LOCAL DEFAULT 6  
9: 0000000000000000 81 FUNC GLOBAL DEFAULT 1 main
10: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND printf
11: 0000000000000051 38 FUNC GLOBAL DEFAULT 1 all
12: 0000000000000004 4 OBJECT GLOBAL DEFAULT COM your
13: 0000000000000077 38 FUNC GLOBAL DEFAULT 1 cs361
14: 0000000000000004 1 OBJECT GLOBAL DEFAULT 3 are
15: 0000000000000004 4 OBJECT GLOBAL DEFAULT COM belong
16: 0000000000000000 4 OBJECT GLOBAL DEFAULT 4 to
17: 0000000000000008 37 OBJECT GLOBAL DEFAULT COM us

Hints:

  • Are you seeing puts instead of printf? Check the man pages for what the difference is, and make sure that the compiler can’t optimize away your call to printf. Remember, requirement #1 only mentions the first line of output.
  • Function lengths are very difficult to reproduce - note that for every FUNC, you do not have to duplicate the length (the length is the number of bytes of assembly code chosen by the compiler to execute the body of each function).

Template

There is no skeleton code for this assignment, only a Makefile.

Turn-in instructions

To make sure your submission is complete, try the following in a temporary directory, i.e. create and change into a temporary directory under the /tmp filesystem:

mkdir /tmp/hw1-temp
cd /tmp/hw1-temp
git clone git@git.uicbits.net:cs361-s15/MYUSERNAME.git
cd MYUSERNAME
git checkout hw1
cd hw1
make test

Grading

Grading will be done automatically using a script, so make sure that your readelf output is identical where it matters. The grading script will only consider the bolded parts.

Due Date

This assignment is due Friday, January 23, at 8 AM. See the syllabus for the late turnin policy. This assignment is worth just as much as every other homework, so getting as much credit on it as possible is important (don’t turn it in late!).