In Pass 2 of a Linking Loader, the actual linking and loading of object modules occur. The loader resolves external references by using the symbol table created in Pass 1, replacing symbolic addresses with actual memory addresses. It performs address relocation to adjust addresses based on the modules' assigned memory locations. Finally, the loader loads the relocated and linked object code into memory, ready for execution. This pass ensures all modules are correctly linked, external symbols are resolved, and the program can run seamlessly. The output is an executable program fully prepared to execute in the allocated memory space.
input files:
1> input.txt
H PROGA 000000 000063
D LISTA 000054
R LISTB ENDB LISTC ENDC
T 000020 0A 03201D 77100004 050014
T 000054 0F 100014 000008 004051 000004 100000
M 000024 05 +LISTB
M 000054 06 +LISTC
M 000060 06 +LISTB
M 000060 06 -LISTA
E 000020
H PROGB 000000 00007F
D LISTB 000060 ENDB 000070
R LISTA LISTC ENDY
T 000036 0B 03100000 772027 05100000
T 000070 0F 100000 000008 004051 000004 100060
M 000037 05 +LISTA
M 00003E 05 -LISTA
M 000070 06 -LISTA
M 000070 06 +LISTC
M 00007C 06 +PROGB
M 00007C 06 -LISTA
E 000000
H PROGC 000000 0000051
D LISTC 000030 ENDC 000042
R LISTA LISTB ENDB
T 000018 0C 03100000 77100004 05100000
T 000042 0F 100030 000008 004051 000004 100000
M 00001D 05 +LISTB
M 000021 05 -LISTA
M 000042 06 -LISTA
M 000042 06 +PROGC
M 00004E 06 +LISTB
M 00004E 06 -LISTA
E
END
input files:
2> estab.txt
PROGA ** 4000 63
** LISTA 4054
PROGB ** 4063 7f
** LISTB 40c3
** ENDB 40d3
PROGC ** 40e2 51
** LISTC 4112
** ENDC 4124
starting adresss is 4000
output files:
after modification.txt
3ff0 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
4000 ........ ........ ........ ........
4010 ........ ........ ........ ........
4020 03201D77 1040c705 0014.... ........
4030 ........ ........ ........ ........
4040 ........ ........ ........ ........
4050 ........ 10412600 00080040 51000004
4060 10006f.. ........ ........ ........
4070 ........ ........ ........ ........
4080 ........ ........ ........ ........
4090 ........ ........ ..031040 54772027
40a0 05fbfac ........ ........ ........
40b0 ........ ........ ........ ........
40c0 ........ ........ ........ ........
40d0 ......10 00be0000 08004051 00000410
40e0 006f.... ........ ........ ........
40f0 ........ ........ ....0310 00007710
4100 40c705fb fac.... ........ ........
4110 ........ ........ ........ ........
4120 ........ 1000be00 00080040 51000004
4130 10006f
output files:
before modification.txt
3ff0 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
4000 ........ ........ ........ ........
4010 ........ ........ ........ ........
4020 03201D77 1040c705 0014.... ........
4030 ........ ........ ........ ........
4040 ........ ........ ........ ........
4050 ........ 10412600 00080040 51000004
4060 10006f.. ........ ........ ........
4070 ........ ........ ........ ........
4080 ........ ........ ........ ........
4090 ........ ........ ..031040 54772027
40a0 05fbfac ........ ........ ........
40b0 ........ ........ ........ ........
40c0 ........ ........ ........ ........
40d0 ......10 00be0000 08004051 00000410
40e0 006f.... ........ ........ ........
40f0 ........ ........ ....0310 00007710
4100 40c705fb fac.... ........ ........
4110 ........ ........ ........ ........
4120 ........ 1000be00 00080040 51000004
4130 10006f