Homework Solutions

กฐ Note : Solutions proceeding with * are for reference only

Section 3.2

2. Suppose that a computer primarily uses direct addressing, but has several different instruction formats. What problems does this create for the relocation-bit approach to program relocation? How might these problems be solved?

10. Suppose that you have been given the task of writing an "unloader" - that is, a piece of software that can take the image of a program that has geen loaded and write out an object program that could later be loaded and executed. The computer system uses a relocating loader, so the object program you produce must be capable of being loaded at a location in memory that is different from where your unloader took it. What problems do you see that would prevent you from accomplishing this task?

11. Suppose that you are given two images of a program as it would appear after loading at two different locations in memory. Assume that the images represent the program after it is loaded and relocated, but before any imformation could be used to accomplish the "unloading" task mentioned in Exercise 10.

13. Suggest a design for a one-pass linking loder. What restrictions (if any) would be required? What would be the advantages and disadvantages of such a one-pass loader?

Section 3.3

3. Suppose that the loader is to produce a listing that shows not only the addresses assigned to external symbols, but also the cross-references between control sections in the program being loaded. What information might be useful in such a listing? Briefly describe how you might implement this feature and include a description of any data structures needed.

Section 3.4

3. Consider the following possibilities for the storage, linking, and execution of a user's program.
    a) Store the source program only; reassemble the program and use a linking loader each time it is to be executed.
    b) Store the source and object versiions of the program; use a linking loader each time the program is to executed.
    c) Store the source program and the linked version with external references to library subroutines left unresolved. Use a linking loader each time the program is to be executed.
    d) Store the source program and the linked version with all external references resolved. Use a relocating loader each time the program is to be executed.
    e) Store the source program and the linked version with all external references resolved and all relocation performed. Use an absolute loader each time the program is to be executed.
Under what conditions might each of these approaches be appropriate? Assume that no changes are required in the source progam from one execution to the next.

4. Dynamic linking, as described in Section 3.4.2, works for transfers of control only. How could the implementation be extended so that data references could also cause dynamic loading to occur?