Linker joins code from all used units, determines addresses of variables, functions and procedures, resolves references and generates executable file.

Linking Modules and Creating EXE File

This is the last phase of program compilation - linking all modules and creating the executable file for program.

Marking Used Blocks

Turbo Pascal uses "smart" linker which eleminates code and variables that are never referenced. This reduces code size and memory usage.

Calculating Offsets of Code Blocks

This procedure calculates offset of each program code block and total code size.

Calculating Offsets of Variables

This procedure calculates offset in data segment for each block of typed constants and variables and checks total data size.

Resolving References

Once the offsets of code blocks, variables and typed constants are known the compiler can resolve references.

Creating Executable File

This procedure creates space in heap for exe header and typed constants, creates exe file and positions it to the start of the code.

© 2021 Turbo Pascal | Privacy Policy