Professional Documents
Culture Documents
Relocation
Loaders that allow for program relocation are called relocating loaders or relative loaders. The need for program relocation is a consequence of the change to larger and more powerful computers.
A modification record is used to describe each part of the object code that must be changed when the program is relocated. A relocation bit associated with each word of object code is used to indicate whether or not this word should be changed when the program is relocated. Some computers provide a hardware relocation capability that eliminates some of the need for the loader to perform program relocation.
3
Relocation bit
Hardware relocation
Modification record
In the object program, there is one Modification record for each value that must be changed during relocation. Each modification record specifies the starting address and length of the field whose value is to be altered.
Col. 11 Col. Col. 2-7 Col. 2-7 M M Starting location of the address field to be modified, relative to the Starting location of the address field to be modified, relative to the beginning of the program beginning of the program Col. 8-9 Length of the address field to be modified, in half-bytes Col. 8-9 Length of the address field to be modified, in half-bytes
If the field contains an odd number of half-bytes, the starting location begins in If the field contains an odd number of half-bytes, the starting location begins in the middle of the first byte. the middle of the first byte.
4
the same as the absolute program with starting address 0 Modification records
actual address
6
The standard SIC machine does not use relative addressing. Therefore, in this program the addresses in all the instructions except RSUB must be modified when the program is relocated. This would enlarge the size of the object program.
Relocation bit
On a machine that
it is often more efficient to specify relocation using the technique of the relocation bit. A relocation bit associated with each word of object code is used to indicate whether or not this word should be changed when the program is relocated.
If the relocation bit corresponding to a word of object code is set to 1, the programs starting address is to be added to this word when the program is relocated. A bit value of 0 indicates that no modification is necessary. The bits corresponding to unused words are set to 0.
10
1111111111002
1 1 1 1 1 1 1 1 1 1 0 0
1110000000002
1 1 1 0 0 0 0 0 0 0 0 0
each relocation bit is associated with a 3-byte segment of object code in the Text record.
11
Program linking
To link control sections together.
12
PROGA
evaluate by assembler
13
PROGB
14
PROGC
15
18
It is used to store the name and address of each external symbol in the set of control section being loaded. A hash organization is often used for ESTAB. It is the beginning address in memory where the linked program is to be loaded. Its value is supplied by the operating system. It contains the starting address assigned to the control section currently being scanned by the loader. This value is added to all relative addresses within the control section to convert them to actual addresses.
19
10
ESTAB
Control section Symbol name Address Length
0063
007F
0051
22
11
Reference number
Eachexternal reference in aacontrol section is Each external reference in control section is assigned aareference number. assigned reference number. Themain advantage of this reference-number The main advantage of this reference-number mechanism is that ititavoids multiple searches of mechanism is that avoids multiple searches of ESTAB for the same symbol during the loading of ESTAB for the same symbol during the loading of control section. control section.
Anexternal reference symbol can be looked up once in An external reference symbol can be looked up once in ESTAB once for each control section that uses it. ESTAB once for each control section that uses it. Thevalues for code modification can then be obtained by The values for code modification can then be obtained by simply indexing into an array of these values. simply indexing into an array of these values.
12