Linkerloader
Linkerloader
Compiler:
Translates high-level language program into assembly language.
Assembler:
Converts assembly language programs into object files.
Object files contain a combination of machine instructions, data, and
information needed to place instructions properly in memory.
Flow of Execution
Translator
.Obj
Linker
.exe
Loader
Program
execution
Process for producing an
executable file
Linker
Tool that merges the object files produced by separate compilation or assembly and creates
an executable file.
• Three tasks:-
Relocation, which modifies the object program so that it can be loaded at an address
different from the location originally specified.
❑ It combines two or more separate object programs and supplies the information needed to
allow references between them .
Linking Concepts
✔ Local symbols, used internally within the object file to facilitate relocation.
Static Linking
► Static linking occurs when a calling program is linked to a called program in a single executable
module. When the program is loaded, the operating system places into memory a single file that
contains the executable code and data.
► The result of statically linking programs is an .EXE file or dynamic link library (DLL)
subprogram that contains the executable code for multiple programs. This file includes both the
calling program and the called program.
► The advantage of static linking is that you can create self-contained, independent programs. In
other words, the executable program consists of one part (the .EXE file) that you need to keep
track of.
► Disadvantages:
We cannot change the behavior of executable files without relinking them.
► External called programs cannot be shared, requiring that duplicate copies of programs be
loaded in memory if more than one calling program needs to access them.
Dynamic linking
► Advantages:
► Often-used libraries (for example the standard system libraries) need to be stored in only one
location, not duplicated in every single binary.
► If an error in a library function is corrected by replacing the library, all programs using it
dynamically will benefit from the correction after restarting them. Programs that included
this function by static linking would have to be re-linked first.
► Disadvantages:
► Known on the Windows platform as "DLL Hell", an incompatible updated DLL will break
executables that depended on the behavior of the previous DLL.
► A program, together with the libraries it uses, might be certified (e.g. as to correctness,
documentation requirements, or performance) as a package, but not if components can be
replaced.
Loader
It is a SYSTEM PROGRAM that brings an executable file residing on disk into memory and starts it
running.
Steps:-
– Read executable file’s header to determine the size of
text and data segments.
– Jumps to a startup routine that copies the program’s arguments from the stack to registers and
calls the program’s main routine.
Types of Loaders
Absolute Program
Advantage:
► Simple and efficient
► No linking or relocation
Disadvantage:
► Difficult to use subroutine libraries.
► The need of programmer to state the actual address.
Algorithm for Absolute Loader
1. begin
2. read Header record
3. verify program name and length
4. read first Text record
5. while record type <> ’E’ do
6. begin
7. {if object code is in character form, convert into
8. internal representation}
9. move object code to specified location in memory
10. read next object program record
11. end
12. jump to address specified in End record
13. end
Bootstrap Loader
1. ABSOLUTE : In this the absolute path of object code is known and the
code is directly loaded in memory.
2. RELATIVE : In this the relative path is known and this relative path is
given by assembler.
Work Of Assembler in Direct Linking Loader