0% found this document useful (0 votes)
12 views15 pages

Os Presentation

Uploaded by

praveen0212402
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views15 pages

Os Presentation

Uploaded by

praveen0212402
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

CONCEPT OF LINKING AND DIFFERENT LINKING

SCHEMES

PRESENTED BY :-
ANAND KUMAR(10009_B1)
ANSHUL PRATAP SINGH(10015_B1)
KAUSHAL KUMAR(10051_B1)
NAVNEET SHARMA(10066_B1)
ANSHUL SINGH(10016_B1)
What is Linking & Linker ?

 Linking is the process of combining various


pieces of code and data into a single
executable file so that a program can run. It
resolves symbolic references between
different program modules (e.g., functions,
variables) and ensures that all dependencies
are correctly mapped.
A linker is a system program that performs
the linking process. It combines multiple object
files generated by a compiler into a single
executable file.
Key Functions of a Linker
Symbol Resolution:
 Resolves references between modules (e.g., linking a
function call to its definition).
Relocation:
 Adjusts addresses in the program to match the final
memory layout.
Combining Modules:
 Merges object files and libraries into an executable
file.
Handling Libraries:
 Includes static or dynamic libraries needed for the
program.
TYPES OF LINKERS

Static Linker:
 Embeds all required code from libraries into
the executable during compile time.

Dynamic Linker:
 Linksshared libraries at runtime, making the
executable smaller and more flexible.
TYPES OF LINKING

 COMPILE TIME LINKING

 LOAD TIME LINKING

 DYNAMIC LINKING
COMPILE-TIME LINKING
 Compile-time linking, also known as static linking, is the process where
all the required object files and libraries are combined into a single
executable file during the compilation phase.

 How Compile-Time Linking Works ?


 Source Code Compilation:
 The compiler converts source code (.c, ,.cpp etc.) into object files (.obj
or .o).
 Linking:
 The linker resolves references between the object files and libraries.
 It combines these files into a single executable file.
 Examples of Compile-Time Linking
 A program that uses a static math library (math.lib) during compilation.
ADVANTAGES

Faster Execution:
 Since all linking is done beforehand, there is no need
to resolve references at runtime.
Portability:
 The executable can run independently without
relying on external libraries.
Simplified Deployment:
 No need to ensure the availability of dynamic
libraries on the target machine.
Disadvantages
 Larger Executable Size:
 All library functions are included, even if some are not
used.
 Inflexibility:
 Updating a library requires recompiling the entire
program.
 Higher Memory Usage:
 Multiple programs using the same library will each
include their own copy of the library, leading to
redundancy.
LOAD-TIME LINKING
 Load-time linking is the process of resolving external references in
a program when it is loaded into memory for execution. Unlike
compile-time linking, which occurs before execution, load-time
linking delays the linking process until just before the program
starts running.
How Load-Time Linking Works ?
Compilation:
 The compiler converts source code into object files (.o, .obj).
 These object files contain placeholders for external references
(e.g., library functions).
Partial Linking:
 The linker generates an intermediate program (not fully resolved),
leaving unresolved references for later.
Loading:
 When the program is loaded into memory, the operating system's
loader resolves the unresolved references by linking them to the
Advantages
Memory Efficiency:
 Shared libraries are loaded only once and can
be shared by multiple programs.
Reduced File Size:
 The executable does not contain library code,
making it smaller than a statically linked
program.
Flexibility:
 Librariescan be updated without recompiling
the program, as long as the interface remains
consistent.
Disadvantages

Slightly Slower Startup:


 Resolving
references at load time adds a delay
when the program starts.
Dependency on Libraries:
 Therequired libraries must be present and
compatible at runtime, or the program cannot
execute.
Dynamic Linking
 Dynamic linking is a process where the linking
of external libraries or modules to a program is
performed at runtime, rather than during
compilation or program loading. This allows
the program to load and use the necessary
library or module only when it is needed
during execution.
How Dynamic Linking Works ?
Compilation:
 The compiler creates an executable file with
references (placeholders) to external libraries,
rather than embedding the library code.
Load-Time or Run-Time Linking:
 Theprogram requests the operating system to
load the required library into memory at
runtime
Dynamic Linking Loader:
 The OS or runtime environment resolves the
symbolic references and binds the required
library dynamically to the program.
Advantages
1. Memory Efficiency:
1. Shared libraries reduce memory usage as
multiple programs share the same library.
2. Flexibility:
1. Librariescan be updated independently of
the program, without recompiling the
application.
3. Reduced File Size:
1. Executable files are smaller because the
library code is not embedded.
Disadvantages
Runtime Overhead:
 Resolvingreferences during execution may
slow down the program slightly.
Dependency Management:
 Ifa required library is missing, corrupted, or
incompatible, the program may fail to run.
Security Concerns:
 Dynamically loaded libraries may introduce
vulnerabilities if not handled securely.

You might also like