Assignment 2, due Feb. 7 (date changed due to snow)
Part of
the homework for 22C:112, Spring 2011
|
On every assignment, write your name legibly as it appears on your University ID and on the class list! Assignments are due at the start of class on the day indicated (usually Friday). Exceptions will be by advance arrangement unless there is what insurance companies call "an act of God" (something outside your control). Homework must be turned in on paper, either in class or in the teaching assistant's mailbox. Never push late work under someone's door!
In a conventional linker, when memory location x is marked as a reference to label L, once the value of L is found during linking, the linker simply does M[x]=value(L) in order to link the instruciton to the label.
a) If the reference to label L is in the context of a PC-relative branch or call instruction, how does th linker link the instruction to the label? (0.5 points)
b) Position independent code allows the program's code to be loaded anywhere in memory without relocation. Does it give similar freedom with respect to the program's stack segment? (0.5 points)
c) Position independent code allows the program's code to be loaded anywhere in memory without relocation. Does it give similar freedom with respect to the program's static segment? (0.5 points)
The following shell commands build (in the appropriate combination) book.pdf from all of the above, plus several intermediate files (simplified):
In the above, some files are both read and written by the same shell command. In these cases, the original is read first, and then the replacement written.
A Problem: Write a makefile to generate book.pdf. (There is no perfect answer because of the cyclic dependencies between some of the files.) (1.0 points)
The C standard library includes a number of string manipulation routines, notably strncpy() for copying a null-terminated string, strstr() searches for one null-terminated string within another, and strchr() searches for the first occurance of a character in a string.
A Problem: Write a brief chunk of code to enumerate the successive directory names in the current search path. (0.5 points)
Take the crummy shell distributed as http://homepage.cs.uiowa.edu/~dwjones/opsys/shell.txt and make the following changes:
Submission instructions: Your completed program should be a single file named shell.c (the .txt suffix on the web version was go guarantee that it would display as plain text). Submit your completed work using the submit shell command, giving shell.c ass the file name, and submitting your work for the course c_112 and the assignment mp1. The submit command gives verbose feedback and complete instructions. Follow them.