SlideShare a Scribd company logo
Loaders and Linkers
 Name: Kunj Desai
 Branch: CSE A
 Semester: 5th
 Year: 2016
Translation Hierarchy
 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 the Hierarchy
Flow of Execution
Translator
Linker
Loader
Program
execution
.Obj
.exe
Process for producing an executable file
Explanation to Linker
 Definition: Tool that merges the object files produced by
separate compilation or assembly and creates an
executable file.
 Three tasks done by LINKER:
 Searches the program to find library routines used by
program, e.g. printf(),sqrt(),strcat() and various other.
 Determines the memory locations that code from each
module will occupy and relocates its instructions by
adjusting absolute references.
Explanation to Linker
 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
 Computer programs typically comprise several parts or modules; all these
parts/modules need not be contained within a single object file, and in such
case refer to each other by means of symbols. Typically, an object file can
contain three kinds of symbols:
 Publicly defined symbols, which allow it to be called by other modules , also
called as public definition .
 Externally defined symbols(undefined symbols), which calls the other
modules where these symbols are defined, also called as external reference.
 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.
Advantages and Disadvantages
 Advantages
 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:
 You cannot change the behavior of executable files
without re-linking 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
 Many operating system environments allow dynamic
linking, that is the postponing of the resolving of some
undefined symbols until a program is run.
 That means that the executable code still contains
undefined symbols, plus a list of objects or libraries
that will provide definitions for these. Loading the
program will load these objects/libraries as well, and
perform a final linking.
Advantages
 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
 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.
Definition of Loader
 Loader is utility program which takes object code as
input prepares it for execution and loads the
executable code into the memory. Thus loader is
actually responsible for initiating the execution
process.
 It is a SYSTEM PROGRAM that brings an executable
file residing on disk into memory and starts it running.
Functions of Loader
 The loader is responsible for the activities such as allocation, linking ,
relocation and loading:
1) It allocates the space for program in the memory, by calculating the
size of the program. This activity is called allocation.
2) It resolves the symbolic references (code/data) between the object
modules by assigning all the user subroutine and library subroutine
addresses. This activity is called linking.
3) There are some address dependent locations in the program, such
address constants must be adjusted according to allocated space, such
activity done by loader is called relocation.
Functions of Loader
4) Finally it places all the machine instructions and data of corresponding programs and
subroutines into the memory. Thus program now becomes ready for execution, this
activity is called loading.
 Steps:
1. Read executable file’s header to determine the size of text and data segments.
2. Create a new address space for the program. Copies instructions and data into
address space. Copies arguments passed to the program on the stack. Initializes
the machine registers including the stack pointer.
3. 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
 Compile/Assemble and Go loader: In compile and go loader is a link
editor/program loader in which the assembler itself places the assembled
instruction directly into the designated memory locations for execution.
 General Scheme Loader: In this loader scheme, the source program is
converted to object program by some translator (assembler). The loader
accepts these object modules and puts machine instruction and data in
an executable form at their assigned memory. The loader occupies some
portion of main memory.
Types of Loaders
 Absolute Loader: An absolute loader is simple loader which performs loading process
and need not to perform linking and program relocation processes.
 Relocating Loader : When a single subroutine is changed then all the subroutines
need to be reassembled. The task of allocation and linking must be carried out once again.
To avoid this rework a new class of loaders is introduced which is called relocating loader.
 Direct Linking Loader: A Direct linking loader is a general relocating loader and
is the most popular loading scheme presently used. This scheme has an
advantage that it allows the programmer to use multiple procedure and multiple
data segments.

More Related Content

What's hot

FIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer LanguagesFIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer Languages
raksharao
 
Macro-processor
Macro-processorMacro-processor
Macro-processor
Temesgen Molla
 
How to execute a C program
How to execute a C  program How to execute a C  program
How to execute a C program
Leela Koneru
 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
Bansari Shah
 
Linker and Loader Explained
Linker and Loader  ExplainedLinker and Loader  Explained
Linker and Loader Explained
Adarsh Kr Sinha
 
Unit 4 sp macro
Unit 4 sp macroUnit 4 sp macro
Unit 4 sp macro
Deepmala Sharma
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loadersTech_MX
 
System Programming- Unit I
System Programming- Unit ISystem Programming- Unit I
System Programming- Unit I
Saranya1702
 
Unit 3
Unit 3Unit 3
Unit 3
pm_ghate
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programming
sonalikharade3
 
Ss4
Ss4Ss4
Assembler design option
Assembler design optionAssembler design option
Assembler design optionMohd Arif
 
Unit 2
Unit 2Unit 2
Unit 2
pm_ghate
 
Macro assembler
 Macro assembler Macro assembler
Macro assembler
Meghaj Mallick
 
Assemblers
AssemblersAssemblers
Assemblers
Dattatray Gandhmal
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
Karan Deopura
 
Problem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CProblem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to C
Prabu U
 
Instruction format
Instruction formatInstruction format
Instruction format
Sanjeev Patel
 

What's hot (20)

Linkers
LinkersLinkers
Linkers
 
FIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer LanguagesFIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer Languages
 
Macro-processor
Macro-processorMacro-processor
Macro-processor
 
How to execute a C program
How to execute a C  program How to execute a C  program
How to execute a C program
 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
 
Linker and Loader Explained
Linker and Loader  ExplainedLinker and Loader  Explained
Linker and Loader Explained
 
Unit 4 sp macro
Unit 4 sp macroUnit 4 sp macro
Unit 4 sp macro
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loaders
 
Assembler
AssemblerAssembler
Assembler
 
System Programming- Unit I
System Programming- Unit ISystem Programming- Unit I
System Programming- Unit I
 
Unit 3
Unit 3Unit 3
Unit 3
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programming
 
Ss4
Ss4Ss4
Ss4
 
Assembler design option
Assembler design optionAssembler design option
Assembler design option
 
Unit 2
Unit 2Unit 2
Unit 2
 
Macro assembler
 Macro assembler Macro assembler
Macro assembler
 
Assemblers
AssemblersAssemblers
Assemblers
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Problem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CProblem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to C
 
Instruction format
Instruction formatInstruction format
Instruction format
 

Similar to Loaders and Linkers

Hm system programming class 1
Hm system programming class 1Hm system programming class 1
Hm system programming class 1
Hitesh Mohapatra
 
Linking in MS-Dos System
Linking in MS-Dos SystemLinking in MS-Dos System
Linking in MS-Dos System
Satyamevjayte Haxor
 
linkerloader ss-2.pptx
linkerloader ss-2.pptxlinkerloader ss-2.pptx
linkerloader ss-2.pptx
SUKHPREET SINGH
 
Linkers in compiler
Linkers in compilerLinkers in compiler
Linkers in compiler
Asaad Al-nour
 
linker & loader presentation in Compiler Design
linker & loader presentation in Compiler Designlinker & loader presentation in Compiler Design
linker & loader presentation in Compiler Design
AbhishekKumar117405
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdf
vino108206
 
Introduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic conceptsIntroduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic concepts
ssuserf86fba
 
Module-4 Program Design and Anyalysis.pdf
Module-4 Program Design and Anyalysis.pdfModule-4 Program Design and Anyalysis.pdf
Module-4 Program Design and Anyalysis.pdf
Sitamarhi Institute of Technology
 
System software module 3 presentation file
System software module 3 presentation fileSystem software module 3 presentation file
System software module 3 presentation file
jithujithin657
 
System software module 3 presentation file
System software module 3 presentation fileSystem software module 3 presentation file
System software module 3 presentation file
jithujithin657
 
Loaders complete
Loaders completeLoaders complete
Loaders complete
Faisal Shah
 
Linkers
LinkersLinkers
Linkers
Rahul Dhiman
 
Ch 4 linker loader
Ch 4 linker loaderCh 4 linker loader
Ch 4 linker loader
Malek Sumaiya
 
Build process ppt.pptx
Build process ppt.pptxBuild process ppt.pptx
Build process ppt.pptx
SHIVANISRECECE
 
Loading executable apps into memory
Loading executable apps into memoryLoading executable apps into memory
Loading executable apps into memory
Sergei Iashin
 
DLL Tutor maXbox starter28
DLL Tutor maXbox starter28DLL Tutor maXbox starter28
DLL Tutor maXbox starter28
Max Kleiner
 
Compliers and interpreters
Compliers and interpretersCompliers and interpreters
Compliers and interpreters
shivasdhtsvmic
 
Ch 1.pptx
Ch 1.pptxCh 1.pptx
Ch 1.pptx
woldu2
 
Consuming and Creating Libraries in C++
Consuming and Creating Libraries in C++Consuming and Creating Libraries in C++
Consuming and Creating Libraries in C++
Richard Thomson
 

Similar to Loaders and Linkers (20)

Hm system programming class 1
Hm system programming class 1Hm system programming class 1
Hm system programming class 1
 
Linking in MS-Dos System
Linking in MS-Dos SystemLinking in MS-Dos System
Linking in MS-Dos System
 
linkerloader ss-2.pptx
linkerloader ss-2.pptxlinkerloader ss-2.pptx
linkerloader ss-2.pptx
 
Linkers in compiler
Linkers in compilerLinkers in compiler
Linkers in compiler
 
linker & loader presentation in Compiler Design
linker & loader presentation in Compiler Designlinker & loader presentation in Compiler Design
linker & loader presentation in Compiler Design
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdf
 
Introduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic conceptsIntroduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic concepts
 
Module-4 Program Design and Anyalysis.pdf
Module-4 Program Design and Anyalysis.pdfModule-4 Program Design and Anyalysis.pdf
Module-4 Program Design and Anyalysis.pdf
 
System software module 3 presentation file
System software module 3 presentation fileSystem software module 3 presentation file
System software module 3 presentation file
 
System software module 3 presentation file
System software module 3 presentation fileSystem software module 3 presentation file
System software module 3 presentation file
 
Loaders complete
Loaders completeLoaders complete
Loaders complete
 
Linkers
LinkersLinkers
Linkers
 
Ch 4 linker loader
Ch 4 linker loaderCh 4 linker loader
Ch 4 linker loader
 
Build process ppt.pptx
Build process ppt.pptxBuild process ppt.pptx
Build process ppt.pptx
 
System software-loaders
System software-loadersSystem software-loaders
System software-loaders
 
Loading executable apps into memory
Loading executable apps into memoryLoading executable apps into memory
Loading executable apps into memory
 
DLL Tutor maXbox starter28
DLL Tutor maXbox starter28DLL Tutor maXbox starter28
DLL Tutor maXbox starter28
 
Compliers and interpreters
Compliers and interpretersCompliers and interpreters
Compliers and interpreters
 
Ch 1.pptx
Ch 1.pptxCh 1.pptx
Ch 1.pptx
 
Consuming and Creating Libraries in C++
Consuming and Creating Libraries in C++Consuming and Creating Libraries in C++
Consuming and Creating Libraries in C++
 

More from kunj desai

OLAP operations
OLAP operationsOLAP operations
OLAP operations
kunj desai
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsing
kunj desai
 
Binary Search
Binary SearchBinary Search
Binary Search
kunj desai
 
Introduction to 8085 microprocessor
Introduction to 8085 microprocessorIntroduction to 8085 microprocessor
Introduction to 8085 microprocessor
kunj desai
 
Custom Controls in ASP.net
Custom Controls in ASP.netCustom Controls in ASP.net
Custom Controls in ASP.net
kunj desai
 
JDBC Connectivity Model
JDBC Connectivity ModelJDBC Connectivity Model
JDBC Connectivity Model
kunj desai
 
Requirement specification (SRS)
Requirement specification (SRS)Requirement specification (SRS)
Requirement specification (SRS)
kunj desai
 
Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
kunj desai
 
php databse handling
php databse handlingphp databse handling
php databse handling
kunj desai
 
Concept of constructors
Concept of constructorsConcept of constructors
Concept of constructors
kunj desai
 

More from kunj desai (10)

OLAP operations
OLAP operationsOLAP operations
OLAP operations
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsing
 
Binary Search
Binary SearchBinary Search
Binary Search
 
Introduction to 8085 microprocessor
Introduction to 8085 microprocessorIntroduction to 8085 microprocessor
Introduction to 8085 microprocessor
 
Custom Controls in ASP.net
Custom Controls in ASP.netCustom Controls in ASP.net
Custom Controls in ASP.net
 
JDBC Connectivity Model
JDBC Connectivity ModelJDBC Connectivity Model
JDBC Connectivity Model
 
Requirement specification (SRS)
Requirement specification (SRS)Requirement specification (SRS)
Requirement specification (SRS)
 
Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
 
php databse handling
php databse handlingphp databse handling
php databse handling
 
Concept of constructors
Concept of constructorsConcept of constructors
Concept of constructors
 

Recently uploaded

RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 

Recently uploaded (20)

RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 

Loaders and Linkers

  • 1. Loaders and Linkers  Name: Kunj Desai  Branch: CSE A  Semester: 5th  Year: 2016
  • 2. Translation Hierarchy  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.
  • 3. Flow of the Hierarchy
  • 5. Process for producing an executable file
  • 6. Explanation to Linker  Definition: Tool that merges the object files produced by separate compilation or assembly and creates an executable file.  Three tasks done by LINKER:  Searches the program to find library routines used by program, e.g. printf(),sqrt(),strcat() and various other.  Determines the memory locations that code from each module will occupy and relocates its instructions by adjusting absolute references.
  • 7. Explanation to Linker  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 .
  • 8. Linking Concepts  Computer programs typically comprise several parts or modules; all these parts/modules need not be contained within a single object file, and in such case refer to each other by means of symbols. Typically, an object file can contain three kinds of symbols:  Publicly defined symbols, which allow it to be called by other modules , also called as public definition .  Externally defined symbols(undefined symbols), which calls the other modules where these symbols are defined, also called as external reference.  Local symbols, used internally within the object file to facilitate relocation.
  • 9. 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.
  • 10. Advantages and Disadvantages  Advantages  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:  You cannot change the behavior of executable files without re-linking 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.
  • 11. Dynamic linking  Many operating system environments allow dynamic linking, that is the postponing of the resolving of some undefined symbols until a program is run.  That means that the executable code still contains undefined symbols, plus a list of objects or libraries that will provide definitions for these. Loading the program will load these objects/libraries as well, and perform a final linking.
  • 12. Advantages  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.
  • 13. Disadvantages  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.
  • 14. Definition of Loader  Loader is utility program which takes object code as input prepares it for execution and loads the executable code into the memory. Thus loader is actually responsible for initiating the execution process.  It is a SYSTEM PROGRAM that brings an executable file residing on disk into memory and starts it running.
  • 15. Functions of Loader  The loader is responsible for the activities such as allocation, linking , relocation and loading: 1) It allocates the space for program in the memory, by calculating the size of the program. This activity is called allocation. 2) It resolves the symbolic references (code/data) between the object modules by assigning all the user subroutine and library subroutine addresses. This activity is called linking. 3) There are some address dependent locations in the program, such address constants must be adjusted according to allocated space, such activity done by loader is called relocation.
  • 16. Functions of Loader 4) Finally it places all the machine instructions and data of corresponding programs and subroutines into the memory. Thus program now becomes ready for execution, this activity is called loading.  Steps: 1. Read executable file’s header to determine the size of text and data segments. 2. Create a new address space for the program. Copies instructions and data into address space. Copies arguments passed to the program on the stack. Initializes the machine registers including the stack pointer. 3. Jumps to a startup routine that copies the program’s arguments from the stack to registers and calls the program’s main routine.
  • 17. Types of Loaders  Compile/Assemble and Go loader: In compile and go loader is a link editor/program loader in which the assembler itself places the assembled instruction directly into the designated memory locations for execution.  General Scheme Loader: In this loader scheme, the source program is converted to object program by some translator (assembler). The loader accepts these object modules and puts machine instruction and data in an executable form at their assigned memory. The loader occupies some portion of main memory.
  • 18. Types of Loaders  Absolute Loader: An absolute loader is simple loader which performs loading process and need not to perform linking and program relocation processes.  Relocating Loader : When a single subroutine is changed then all the subroutines need to be reassembled. The task of allocation and linking must be carried out once again. To avoid this rework a new class of loaders is introduced which is called relocating loader.  Direct Linking Loader: A Direct linking loader is a general relocating loader and is the most popular loading scheme presently used. This scheme has an advantage that it allows the programmer to use multiple procedure and multiple data segments.

Editor's Notes

  1. <number>