Thursday 31 May 2012

Program linking algorithm


1.Program_linked_origin = <link origin> from linker command
2.For each object module
a.T_origin = translated origin of the object module.  OM_size = size of the object module.
b.Relocation_factor=program_linked_origint_origin.
c.Read the machine language program in work_area.
d.Read LINKTAB of the object module.
e.for each LINKTAB entry with type = public definition                    name=symbol                                                                      linked_address = translated_address + relocation_factor               Enter(name,linked_address) in NTAB.
f.Enter (object module name, program_linked_origin) in NTAB.
g.Program_linked_origin=program_linked_origin+OM_size.
3.For each object module
a.T_origin = translated origin of the object module.
      Program_linked_origin = load_address from NTAB.
b.For each LINKTAB entry with type = EXT
i.Address_in_work_area = address of work_area + program_linked_origin - <link_origin> + translated address – t_origin.
ii.Search symbol in NTAB and copy its linked address. Add the linked address to the operand address in the word with the address address_in_work_area.

No comments:

Post a Comment