Storage Allocation

Prev: Object Files Next: Symbol Management

Problems

4.1

Why does a linker shuffle around segments to put segments of the same type next to each other? Wouldn’t it be easier to leave them in the original order?


4.2

When, if ever, does it matter in what order a linker allocates storage for routines? In our example, what difference would it make if the linker allocated newyork, mass, calif, main rather than main, calif, mass, newyork. (We’ll ask this question again later when we discuss overlays and dynamic linking, so you can disregard those considerations.)


4.3

In most cases a linker allocates similar sections sequentially, for example, the text of calif, mass, and newyork one after another. But it allocates all common sections with the same name on top of each other. Why?


4.4

Is it a good idea to permit common blocks declared in different input files with the same name but different sizes? Why or why not?


4.5

In example 1, assume that the programmer has rewritten the calif routine so that the object code is now hex 1333 long. Recompute the assigned segment locations. In example 2, further assume that the data and bss sizes for the rewritten calif routine are 975 and 120. Recompute the assigned segment locations.