Thursday 31 May 2012

Relocation and Linking concepts


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.
                     Tsymbt_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

5 comments:

  1. Good job..!! Understood the relocation concept in simplest words.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. thanks for such kind of articles.....i clearly understand concept of relocation in simple......

    techno-solution

    ReplyDelete
  4. Hi,
    Thanks for sharing such kind of information, its nice article about relocation. I got clear idea of relocation regarding program relocation.
    http://alphasoftglobal.com/mlm-software/mlm-software-company-Pune

    ReplyDelete