Hardware Reference
In-Depth Information
contain the character string ''bigbug'' followed by the address to which it corre-
sponds. The assembly language programmer indicates which symbols are to be
declared as entry points by using a pseudoinstruction such as PUBLIC in Fig. 7-2.
The third part of the object module consists of a list of the symbols that are
used in the module but which are defined in other modules, along with a list of
which machine instructions use which symbols. The linker needs the latter list in
order to be able to insert the correct addresses into the instructions that use external
symbols. A procedure can call other independently translated procedures by
declaring the names of the called procedures to be external. The assembly lan-
guage programmer indicates which symbols are to be declared as external sym-
bols by using a pseudoinstruction such as EXTERN in Fig. 7-2. On some computers
entry points and external references are combined into one table.
The fourth part of the object module is the assembled code and constants. This
part of the object module is the only one that will be loaded into memory to be ex-
ecuted. The other five parts will be used by the linker to help it do its work and
then discarded before execution begins.
The fifth part of the object module is the relocation dictionary. As shown in
Fig. 7-14, instructions that contain memory addresses must have a relocation con-
stant added. Since the linker has no way of telling by inspection which of the data
words in part four contain machine instructions and which contain constants, infor-
mation about which addresses are to be relocated is provided in this table. The
information may take the form of a bit table, with 1 bit per potentially relocatable
address, or an explicit list of addresses to be relocated.
The sixth part is an end-of-module mark, perhaps a checksum to catch errors
made while reading the module, and the address at which to begin execution.
Most linkers require two passes. On pass one the linker reads all the object
modules and builds up a table of module names and lengths, and a global symbol
table consisting of all entry points and external references. On pass two the object
modules are read, relocated, and linked one module at a time.
7.4.3 Binding Time and Dynamic Relocation
In a multiprogramming system, a program can be read into main memory, run
for a little while, written to disk, and then read back into main memory to be run
again. In a large system, with many programs, it is difficult to ensure that a pro-
gram is read back into the same locations every time.
Figure 7-16 shows what would happen if the already relocated program of
Fig. 7-14(b) were reloaded at address 400 instead of address 100 where the linker
put it originally. All the memory addresses are incorrect; moreover, the relocation
information has long since been discarded. Even if the relocation information
were still available, the cost of having to relocate all the addresses every time the
program was swapped would be too high.
 
 
Search WWH ::




Custom Search