L2. Program creation process

Phases of program creation

Compilation

Linker doesn't know the source language of the module
Libraries contain ready-to-use, precompiled object modules stored in a modified (archived) form

Compilation

HLL compiler creates assembler form of each compiler module
may be stored in a file or supplied directly to the assembler via a pipe
later translated by assembler into an object file
some compilers create object files directly, without intermediate assembly

Assembly

Process of translating assembler source into aon object or executable file
Assembly source may be created by compiler or written by a programmer

Object form

Contain binary executable code with some references marked as undefined
Usually executable program consists of many linked modules
module may reference variables and functions defined in other modules
OBject file contains the description of external references - symbols used but not defined in the module and global, symbols defined in the module, made available to other modules

Linking

Process of resolving external references by connecting them to symbols defined as globals in other modules
Linking of the symbol is possible only if the symbol is defined as external - externally-defined
Linking to the symbol (target) is possible only if the target is defined as global - publicly available
The result is an exectable form, with all references resolved
if dynamic libraries are used, final linking occurs during loading the program to computer's memory
Linking fails when:

External symbols

Sybols referenced in a given module, defined in other modules
Must be declared as external in a way depending on the programming language used

Public symbols

Defined in a given module which may be used by other modules
Must be declared as public:

Libraries

Collection of object modules which may be linked to other modules written by programmer
Library file contains archived object files created from several source modules
Starndard library functions are usually supplied with a compiler
Programmer may create his own libraries which may be used by many programs