•Program relocation :
in program instruction and data use some address. Program assumes its
instructions and data to occupy memory words with specific address.
•Such a program is
called an address sensitive program. It contains one or more of the following:
1.An address sensitive
instruction : an instruction which uses an address.
2.An address constant :
a data word which contains an address.
•Definition : program
relocation is the process of modifying the address used in the address
sensitive instructions of a program such that the program can execute correctly
from the designated area of memory.
•In complete process
translation origin and linking are always different. but linking origin and
loading origin may be same or different.
•If loading origin and
linking origin are different this means relocation must be performed by the
loader.
•Linker always
performs relocation. But some loaders do not do this.
•If loaders do not
perform relocation this means load origin and link origin are equal, and this
loader is called absolute loader.
•If loaders perform
relocation then loaders are called relocation loaders.
•Performing relocation
: we can calculate the relocation factor by linking origin and translate
origin. Suppose translated origin and linked origin of program are t_origin and l_origin respectively.
Consider a symbol symb in program P. its translation time address be tsymb and link time address
be lsymb. The relocation
factor of program is defined as
relocation_factor = l_orgin – t_origin
•Relocation factor can
be positive, negative or 0.
•Here symb is working as an operand. The
translator puts the address tsymb in the instruction for it.
• Tsymb = t_origin + dsymb
•where dsymb is the offset of symb in program.
•lsymb = l_origin + dsymb
•lsymb = t_origin +relocation_faction +dsymb
• = t_origin +
dsymb + relocation_factior
• = tsymb + relocation_factor