SlideShare a Scribd company logo
1 of 17
1
2
Introduction
Linker
Linker is a program that takes one or more objects generated by a compiler and combines/assembles them into a single
executable program.
Source program Executable program
Object modules
Loader
Loader is a program that is responsible for loading programs from executables into memory, preparing them for execution
and then executing them.
Source program Executable program
The execution of a program involves the following steps:
Step 1: Translation
Step 2: Linking
Step 3: Relocation
Step 4: Loading
Compiler Linker
Translator Linker Loader Memory Output
Source
Program
Object
modules
Binary
Programs
Data
Loader
3
Concept of Binding
Binding is an association between an attribute and an entity or between an operation and a symbol. The time at which a
binding takes place is called binding time. Binding can take place at language design time, language implementation time,
compile time, link time, or run time. There are two types of binding:
1. Static binding: A static binding is a building before the execution of program begins. It is also called early binding.
2. Dynamic binding: A dynamic binding is a binding performed after the execution of a program begins. It is also called late
binding. Dynamic linking involves the following steps:
1) A reference to an external module during run time causes the loader to find the target module and load it.
2) Perform relocation during run time
Dynamic linking permits a program to load and unload routines at run time.
Binding
Static Binding Dynamic Binding
4
Difference between Static and Dynamic Binding
Static Binding Dynamic Binding
1. Binding between names and objects can be determined at
compile time.
1. Binding between names and objects can be
determined at run time.
2. Binding variable depends on where the procedure is written. 2. Binding depends on who calls the procedure.
3. Output does not differ at runtime. 3. Output differs at runtime.
4. Mostly, compiler is needed. 4. Interpreter is needed.
5. Program is more efficient. 5. Program is more flexible.
6. Example: C language 6. Example: LISP(List Programming)
5
Translator, Link and Load Time Address
Following are some terminology which is very important to understand:
1. Translator: A translator translates a program and convert it into target code. It also allocates memory to all variables
defined in the program.
2. Translation time address: Address assigned by the translator.
3. Linked address: Address assigned by the linker.
4. Load-time address: Address assigned by the loader.
5. Translated origin: Address of the origin assumed by the translator. This is the address specified by the programmer in
an ORIGIN statement.
6. Liked origin: Address of the origin assumed by the linker while producing a binary program.
7. Load origin: Address of the origin assigned by the loader while loading the program for execution.
Example of Translator, Link and Load Time Address
The translated time origin of a program is 200. the translation
time address of LOOP is 201. If the program is loaded for
execution in the memory area starting with the address 500, then
the load time origin is 500 and load time address of LOOP is
501.
 Translation time origin is 200.
 Translation time address of symbol A is 224.
 Link address of A is 524.
 Link address of LOOP becomes 501
7
Types of Loader
Function of Loader
1. Loading - which allocates memory location and brings the object program into memory for execution - (Loader)
2. Linking- which combines two or more separate object programs and supplies the information needed to allow
references between them - (Linker)
3. Relocation - which modifies the object program so that it can be loaded at an address different from the location
originally specified - (Linking Loader)
Based on the above four functions the loader is divided into different types, they are
1. Compile and go loader or Assemble and go loader
2. General loader scheme
3. Absolute loader
4. Direct linking loader
5. Relocating loader
6. Dynamic linking loader
8
1. Compile and Go Loader
 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.
 The instruction are read line by line, its machine code is obtained and it is directly put in the main memory at some
known address.
 After completion of assembly process, it assigns the starting address of the program to the location counter. The
assembler is first executed it & when it is finished, causes a branch straight to the first instruction of the program.
 There is no stop between the compilation, link editing, loading, and execution of the program. It is also called an
assemble-and-go or a load and-go system.
Advantages of Compile-and-go Loaders
 They are simple and easier to implement.
 No additional routines are required to load the compiled code into the memory.
Disadvantages of Compile-and-go Loaders
 Portion of memory is wasted because combination of assembler and loader activities, this combination program occupies
large block of memory
 There is no production of .obj file
 It cannot handle multiple source programs or multiple programs written in different languages
 The execution time will be more in this scheme as every time program is assembled and then executed
9
2. General Loader Scheme
 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.
 Generally the size of loader is less than that of assembler.
Advantage of General Loader Scheme
 In this scheme the source program translators produce compatible object program deck formats and it is possible to
write subroutines in several different languages since the object decks to be processed by the loader will all be in the
same “language” that is in “machine language”.
 The program need not be retranslated each time while running it
 There is no wastage of memory, because assembler is not placed in the memory
 It is possible to write source program with multiple programs and multiple languages
10
3. Absolute Loader
 Absolute loader is a kind of loader in which relocated object files are created, loader accepts these files and places them
at specified locations in the memory. This type of loader is called absolute because no relocation information is needed;
rather it is obtained from the programmer or assembler.
 The starting address of every module is known to the programmer, this corresponding starting address is stored in the
object file, then task of loader becomes very simple and that is to simply place the executable form of the machine
instructions at the locations mentioned in the object file.
 In this scheme the programmer or assembler should have knowledge of memory management. The resolution of external
references or linking of different subroutines are the issues which need to be handled by the programmer.
 Thus the absolute loader is simple to implement in this scheme
1. Allocation is done by either programmer or assembler
2. Linking is done by the programmer or assembler
3. Resolution is done by assembler
4. Simply loading is done by the loader
Disadvantages
 The programmer must specify to the assembler the address where the program is to be loaded.
 If there are multiple subroutines , the programmer must remember the address of each.
11
4. Direct Linking Loader
 The direct linking loader is the most common type of loader. The loader cannot have the direct access to the source
code. The assembler should give the following information to the loader
i. The length of the object code segment
ii. The list of all the symbols which are not defined in the current segment but can be used in the current segment.
iii. The list of all the symbols which are defined in the current segment but can be referred by the other segments.
 The list of symbols which are not defined in the current segment but can be used in the current segment are stored in a
data structure called USE table. The list of symbols which are defined in the current segment and can be referred by the
other segments are stored in a data structure called DEFINITION table.
 There are 4 types of cards available in the direct linking loader. They are
1. ESD-External symbol dictionary
2. TXT-card
3. RLD-Relocation and linking dictionary
4. END-card
1. ESD card: It contains information about all symbols that are defined in the program but reference somewhere, It
contains:
 Reference number
 Symbol name
 Type Id
 Relative location
 Length
12
2. TXT Card: It contains the actual information are text which are already translated.
3. RLD Card: This card contains information about location in the program whose contexts depends on the address at
which the program is placed. In this we are used ‘+’ and ‘–‘sign, when we are using the ‘+’ sign then no need of relocation,
when we are using ‘-‘sign relocation is necessary. The format of RLD contains:
i. Reference number
ii. Symbol
iii. Flag
iv. Length
v. Relative location
4. END Card: It indicates end of the object program.
Disadvantage
 Allocate, relocate, link, and load all the subroutines each time in order to execute a program.
 Furthermore, even though loader program smaller than assembler, it absorb considerable amount of memory.
13
5. Relocating Loader
 To avoid possible assembling of all subroutines when a single subroutine is change and to perform the tasks of allocation
and linking for the programmer, the general class of relocating loader was introduced. The output of a relocating loader is
the program and information about all other programs it references. In addition, there is information (relocation
information) as to location in this program that must be change if it is to be loaded in an arbitrary location in memory. In
the given program X variable will be at 30. But after loading it will be loaded at 530. The address of variable ‘X’ can be
found as given below:
500 + 30 = 530
Segment register offset actual address
14
6. Dynamic Linking Loader
 Dynamic Linking Loader is a general re-locatable loader
 Allowing the programmer multiple procedure segments and multiple data segments and giving programmer complete
freedom in referencing data or instruction contained in other segments.
 The assembler must give the loader the following information with each procedure or data segment.
 Dynamic linking defers much of the linking process until a program starts running. It provides a variety of benefits that
are hard to get otherwise.
 Dynamically linked shared libraries are easier to create than static linked shared libraries.
 Dynamically linked shared libraries are easier to update than static linked shared libraries.
 The semantics of dynamically linked shared libraries can be much closer to those of unshared libraries.
 Dynamic linking permits a program to load and unload routines at runtime, a facility that can otherwise be very
difficult to provide.
15
The object module of a program contain all information necessary to relocate and link the program with other program.
Object module of a program P consists of 4 components:
1. Header: contain translated origin, size & execution start address of P.
2. Program: contain machine language program corresponding to P.
3. Relocation table: each RELOCTAB contain a single field. Translated address: of an address sensitive instruction.
4. Linking table(LINKTAB): contain information about public definition and external references in P.
Each LINKTAB entry contain three fields:
1. Symbol: symbolic name
2. Type: PD/ EXT indicating whether public or external.
3. Translated address:
for public: add. of first memory word allocated to the
symbol.
for external: add. Of memory word which is required to
contain address of the symbol.
Object Module
16
Program can be classified into 3 categories:
1. Non-relocatable program
2. Relocatable program
3. Self-relocatable program
1. Non-relocatable program: It is a program which cannot be executed in any memory area other than the area
starting on its translated origin. Non-relocatability is the result of address-sensitivity of the code and lack of
information regarding: which part of the program are address sensitive and in which manner. Example: .com files on
DOS
2. Relocatable program: It is the one which consists of a program and relevant information for its relocation. These
program contains information of address sensitive instruction. At relocation of the program, the relocation factor is
added to address part of the address sensitive instruction. This process is generally done by operating system and the
output which perform relocation is called linkage editor relocating loader. Example: .exe files on DOS
Program Relocatability
Program + Data
Program + Data
___________________
Relocation information
3. Self-relocatable program: Self-relocating program is a program which can perform the relocation of its own
address sensitive instruction. It contains the followings:
1. A table of information about address sensitive instructions in the program.
2. Relocating logic that can perform the relocation of the address sensitive instructions
 Self relocating contain the relocating logic that can perform the relocation of the address sensitive instructions. So
there is no need of a linker in self relocating program.
 It uses the load address and the information concerning address sensitive instruction to perform its own relocation.
Commonly used compilers like TC, FORTRAN, COBOL in multiuser system contain code for self-relocation.
These programs can execute in any area of the memory.
 Thus, if the non-relocatable compiler is used then it is necessary to keep ‘n’ copies of compiler for each user. It
requires large storage.
 If relocatable compiler is used then it is necessary to load linkage editor each time and relocate the program each
time when program is execute. Thus, even if storage for n copies is saved by retaining one copy only, the storage
is required for , linkage editor.
Program Relocatability
Relocating Logic
Program + Data
Relocation Information

More Related Content

What's hot (20)

Macro Processor
Macro ProcessorMacro Processor
Macro Processor
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
 
Ch 4 linker loader
Ch 4 linker loaderCh 4 linker loader
Ch 4 linker loader
 
Unit 4 sp macro
Unit 4 sp macroUnit 4 sp macro
Unit 4 sp macro
 
Assembler
AssemblerAssembler
Assembler
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
 
System software
System softwareSystem software
System software
 
Code generation
Code generationCode generation
Code generation
 
Unit 3
Unit 3Unit 3
Unit 3
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Loaders
LoadersLoaders
Loaders
 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
 
Loaders and Linkers
Loaders and LinkersLoaders and Linkers
Loaders and Linkers
 
Run time storage
Run time storageRun time storage
Run time storage
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
 
Language processors
Language processorsLanguage processors
Language processors
 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language Processing
 
Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loader
 
Ch 3 Assembler in System programming
Ch 3 Assembler in System programming Ch 3 Assembler in System programming
Ch 3 Assembler in System programming
 

Similar to Linker and Loader

Loader and Its types
Loader and Its typesLoader and Its types
Loader and Its typesParth Dodiya
 
System software module 3 presentation file
System software module 3 presentation fileSystem software module 3 presentation file
System software module 3 presentation filejithujithin657
 
System software module 3 presentation file
System software module 3 presentation fileSystem software module 3 presentation file
System software module 3 presentation filejithujithin657
 
Hm system programming class 1
Hm system programming class 1Hm system programming class 1
Hm system programming class 1Hitesh Mohapatra
 
system prgramming - loaders-linkers.pdf
system prgramming - loaders-linkers.pdfsystem prgramming - loaders-linkers.pdf
system prgramming - loaders-linkers.pdfSATHYABAMAMADHANKUMA
 
Compliers and interpreters
Compliers and interpretersCompliers and interpreters
Compliers and interpretersshivasdhtsvmic
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - IntroductionMuhammad Sanaullah
 
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 conceptsssuserf86fba
 
Language processing system.pdf
Language processing system.pdfLanguage processing system.pdf
Language processing system.pdfRakibRahman19
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compilerA. S. M. Shafi
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdfvino108206
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxdawod yimer
 
Build process ppt.pptx
Build process ppt.pptxBuild process ppt.pptx
Build process ppt.pptxSHIVANISRECECE
 
Ch 1.pptx
Ch 1.pptxCh 1.pptx
Ch 1.pptxwoldu2
 
System software module 1 presentation file
System software module 1 presentation fileSystem software module 1 presentation file
System software module 1 presentation filejithujithin657
 

Similar to Linker and Loader (20)

Loader and Its types
Loader and Its typesLoader and Its types
Loader and Its types
 
Handout#12
Handout#12Handout#12
Handout#12
 
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
 
Hm system programming class 1
Hm system programming class 1Hm system programming class 1
Hm system programming class 1
 
linkerloader ss-2.pptx
linkerloader ss-2.pptxlinkerloader ss-2.pptx
linkerloader ss-2.pptx
 
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 prgramming - loaders-linkers.pdf
system prgramming - loaders-linkers.pdfsystem prgramming - loaders-linkers.pdf
system prgramming - loaders-linkers.pdf
 
Compliers and interpreters
Compliers and interpretersCompliers and interpreters
Compliers and interpreters
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - Introduction
 
Loaders
LoadersLoaders
Loaders
 
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
 
COMPILER DESIGN.docx
COMPILER DESIGN.docxCOMPILER DESIGN.docx
COMPILER DESIGN.docx
 
Language processing system.pdf
Language processing system.pdfLanguage processing system.pdf
Language processing system.pdf
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdf
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptx
 
Build process ppt.pptx
Build process ppt.pptxBuild process ppt.pptx
Build process ppt.pptx
 
Ch 1.pptx
Ch 1.pptxCh 1.pptx
Ch 1.pptx
 
System software module 1 presentation file
System software module 1 presentation fileSystem software module 1 presentation file
System software module 1 presentation file
 

More from sonalikharade3

SIMULATING A SIMPLE MACHINE (smaco)
SIMULATING A SIMPLE MACHINE (smaco)SIMULATING A SIMPLE MACHINE (smaco)
SIMULATING A SIMPLE MACHINE (smaco)sonalikharade3
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programmingsonalikharade3
 
Phishing Attack Awareness and Prevention
Phishing Attack Awareness and PreventionPhishing Attack Awareness and Prevention
Phishing Attack Awareness and Preventionsonalikharade3
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligencesonalikharade3
 
COMPILER DESIGN OPTIONS
COMPILER DESIGN OPTIONSCOMPILER DESIGN OPTIONS
COMPILER DESIGN OPTIONSsonalikharade3
 

More from sonalikharade3 (6)

EDITORS
EDITORSEDITORS
EDITORS
 
SIMULATING A SIMPLE MACHINE (smaco)
SIMULATING A SIMPLE MACHINE (smaco)SIMULATING A SIMPLE MACHINE (smaco)
SIMULATING A SIMPLE MACHINE (smaco)
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programming
 
Phishing Attack Awareness and Prevention
Phishing Attack Awareness and PreventionPhishing Attack Awareness and Prevention
Phishing Attack Awareness and Prevention
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
COMPILER DESIGN OPTIONS
COMPILER DESIGN OPTIONSCOMPILER DESIGN OPTIONS
COMPILER DESIGN OPTIONS
 

Recently uploaded

Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 

Recently uploaded (20)

Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 

Linker and Loader

  • 1. 1
  • 2. 2 Introduction Linker Linker is a program that takes one or more objects generated by a compiler and combines/assembles them into a single executable program. Source program Executable program Object modules Loader Loader is a program that is responsible for loading programs from executables into memory, preparing them for execution and then executing them. Source program Executable program The execution of a program involves the following steps: Step 1: Translation Step 2: Linking Step 3: Relocation Step 4: Loading Compiler Linker Translator Linker Loader Memory Output Source Program Object modules Binary Programs Data Loader
  • 3. 3 Concept of Binding Binding is an association between an attribute and an entity or between an operation and a symbol. The time at which a binding takes place is called binding time. Binding can take place at language design time, language implementation time, compile time, link time, or run time. There are two types of binding: 1. Static binding: A static binding is a building before the execution of program begins. It is also called early binding. 2. Dynamic binding: A dynamic binding is a binding performed after the execution of a program begins. It is also called late binding. Dynamic linking involves the following steps: 1) A reference to an external module during run time causes the loader to find the target module and load it. 2) Perform relocation during run time Dynamic linking permits a program to load and unload routines at run time. Binding Static Binding Dynamic Binding
  • 4. 4 Difference between Static and Dynamic Binding Static Binding Dynamic Binding 1. Binding between names and objects can be determined at compile time. 1. Binding between names and objects can be determined at run time. 2. Binding variable depends on where the procedure is written. 2. Binding depends on who calls the procedure. 3. Output does not differ at runtime. 3. Output differs at runtime. 4. Mostly, compiler is needed. 4. Interpreter is needed. 5. Program is more efficient. 5. Program is more flexible. 6. Example: C language 6. Example: LISP(List Programming)
  • 5. 5 Translator, Link and Load Time Address Following are some terminology which is very important to understand: 1. Translator: A translator translates a program and convert it into target code. It also allocates memory to all variables defined in the program. 2. Translation time address: Address assigned by the translator. 3. Linked address: Address assigned by the linker. 4. Load-time address: Address assigned by the loader. 5. Translated origin: Address of the origin assumed by the translator. This is the address specified by the programmer in an ORIGIN statement. 6. Liked origin: Address of the origin assumed by the linker while producing a binary program. 7. Load origin: Address of the origin assigned by the loader while loading the program for execution.
  • 6. Example of Translator, Link and Load Time Address The translated time origin of a program is 200. the translation time address of LOOP is 201. If the program is loaded for execution in the memory area starting with the address 500, then the load time origin is 500 and load time address of LOOP is 501.  Translation time origin is 200.  Translation time address of symbol A is 224.  Link address of A is 524.  Link address of LOOP becomes 501
  • 7. 7 Types of Loader Function of Loader 1. Loading - which allocates memory location and brings the object program into memory for execution - (Loader) 2. Linking- which combines two or more separate object programs and supplies the information needed to allow references between them - (Linker) 3. Relocation - which modifies the object program so that it can be loaded at an address different from the location originally specified - (Linking Loader) Based on the above four functions the loader is divided into different types, they are 1. Compile and go loader or Assemble and go loader 2. General loader scheme 3. Absolute loader 4. Direct linking loader 5. Relocating loader 6. Dynamic linking loader
  • 8. 8 1. Compile and Go Loader  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.  The instruction are read line by line, its machine code is obtained and it is directly put in the main memory at some known address.  After completion of assembly process, it assigns the starting address of the program to the location counter. The assembler is first executed it & when it is finished, causes a branch straight to the first instruction of the program.  There is no stop between the compilation, link editing, loading, and execution of the program. It is also called an assemble-and-go or a load and-go system. Advantages of Compile-and-go Loaders  They are simple and easier to implement.  No additional routines are required to load the compiled code into the memory. Disadvantages of Compile-and-go Loaders  Portion of memory is wasted because combination of assembler and loader activities, this combination program occupies large block of memory  There is no production of .obj file  It cannot handle multiple source programs or multiple programs written in different languages  The execution time will be more in this scheme as every time program is assembled and then executed
  • 9. 9 2. General Loader Scheme  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.  Generally the size of loader is less than that of assembler. Advantage of General Loader Scheme  In this scheme the source program translators produce compatible object program deck formats and it is possible to write subroutines in several different languages since the object decks to be processed by the loader will all be in the same “language” that is in “machine language”.  The program need not be retranslated each time while running it  There is no wastage of memory, because assembler is not placed in the memory  It is possible to write source program with multiple programs and multiple languages
  • 10. 10 3. Absolute Loader  Absolute loader is a kind of loader in which relocated object files are created, loader accepts these files and places them at specified locations in the memory. This type of loader is called absolute because no relocation information is needed; rather it is obtained from the programmer or assembler.  The starting address of every module is known to the programmer, this corresponding starting address is stored in the object file, then task of loader becomes very simple and that is to simply place the executable form of the machine instructions at the locations mentioned in the object file.  In this scheme the programmer or assembler should have knowledge of memory management. The resolution of external references or linking of different subroutines are the issues which need to be handled by the programmer.  Thus the absolute loader is simple to implement in this scheme 1. Allocation is done by either programmer or assembler 2. Linking is done by the programmer or assembler 3. Resolution is done by assembler 4. Simply loading is done by the loader Disadvantages  The programmer must specify to the assembler the address where the program is to be loaded.  If there are multiple subroutines , the programmer must remember the address of each.
  • 11. 11 4. Direct Linking Loader  The direct linking loader is the most common type of loader. The loader cannot have the direct access to the source code. The assembler should give the following information to the loader i. The length of the object code segment ii. The list of all the symbols which are not defined in the current segment but can be used in the current segment. iii. The list of all the symbols which are defined in the current segment but can be referred by the other segments.  The list of symbols which are not defined in the current segment but can be used in the current segment are stored in a data structure called USE table. The list of symbols which are defined in the current segment and can be referred by the other segments are stored in a data structure called DEFINITION table.  There are 4 types of cards available in the direct linking loader. They are 1. ESD-External symbol dictionary 2. TXT-card 3. RLD-Relocation and linking dictionary 4. END-card 1. ESD card: It contains information about all symbols that are defined in the program but reference somewhere, It contains:  Reference number  Symbol name  Type Id  Relative location  Length
  • 12. 12 2. TXT Card: It contains the actual information are text which are already translated. 3. RLD Card: This card contains information about location in the program whose contexts depends on the address at which the program is placed. In this we are used ‘+’ and ‘–‘sign, when we are using the ‘+’ sign then no need of relocation, when we are using ‘-‘sign relocation is necessary. The format of RLD contains: i. Reference number ii. Symbol iii. Flag iv. Length v. Relative location 4. END Card: It indicates end of the object program. Disadvantage  Allocate, relocate, link, and load all the subroutines each time in order to execute a program.  Furthermore, even though loader program smaller than assembler, it absorb considerable amount of memory.
  • 13. 13 5. Relocating Loader  To avoid possible assembling of all subroutines when a single subroutine is change and to perform the tasks of allocation and linking for the programmer, the general class of relocating loader was introduced. The output of a relocating loader is the program and information about all other programs it references. In addition, there is information (relocation information) as to location in this program that must be change if it is to be loaded in an arbitrary location in memory. In the given program X variable will be at 30. But after loading it will be loaded at 530. The address of variable ‘X’ can be found as given below: 500 + 30 = 530 Segment register offset actual address
  • 14. 14 6. Dynamic Linking Loader  Dynamic Linking Loader is a general re-locatable loader  Allowing the programmer multiple procedure segments and multiple data segments and giving programmer complete freedom in referencing data or instruction contained in other segments.  The assembler must give the loader the following information with each procedure or data segment.  Dynamic linking defers much of the linking process until a program starts running. It provides a variety of benefits that are hard to get otherwise.  Dynamically linked shared libraries are easier to create than static linked shared libraries.  Dynamically linked shared libraries are easier to update than static linked shared libraries.  The semantics of dynamically linked shared libraries can be much closer to those of unshared libraries.  Dynamic linking permits a program to load and unload routines at runtime, a facility that can otherwise be very difficult to provide.
  • 15. 15 The object module of a program contain all information necessary to relocate and link the program with other program. Object module of a program P consists of 4 components: 1. Header: contain translated origin, size & execution start address of P. 2. Program: contain machine language program corresponding to P. 3. Relocation table: each RELOCTAB contain a single field. Translated address: of an address sensitive instruction. 4. Linking table(LINKTAB): contain information about public definition and external references in P. Each LINKTAB entry contain three fields: 1. Symbol: symbolic name 2. Type: PD/ EXT indicating whether public or external. 3. Translated address: for public: add. of first memory word allocated to the symbol. for external: add. Of memory word which is required to contain address of the symbol. Object Module
  • 16. 16 Program can be classified into 3 categories: 1. Non-relocatable program 2. Relocatable program 3. Self-relocatable program 1. Non-relocatable program: It is a program which cannot be executed in any memory area other than the area starting on its translated origin. Non-relocatability is the result of address-sensitivity of the code and lack of information regarding: which part of the program are address sensitive and in which manner. Example: .com files on DOS 2. Relocatable program: It is the one which consists of a program and relevant information for its relocation. These program contains information of address sensitive instruction. At relocation of the program, the relocation factor is added to address part of the address sensitive instruction. This process is generally done by operating system and the output which perform relocation is called linkage editor relocating loader. Example: .exe files on DOS Program Relocatability Program + Data Program + Data ___________________ Relocation information
  • 17. 3. Self-relocatable program: Self-relocating program is a program which can perform the relocation of its own address sensitive instruction. It contains the followings: 1. A table of information about address sensitive instructions in the program. 2. Relocating logic that can perform the relocation of the address sensitive instructions  Self relocating contain the relocating logic that can perform the relocation of the address sensitive instructions. So there is no need of a linker in self relocating program.  It uses the load address and the information concerning address sensitive instruction to perform its own relocation. Commonly used compilers like TC, FORTRAN, COBOL in multiuser system contain code for self-relocation. These programs can execute in any area of the memory.  Thus, if the non-relocatable compiler is used then it is necessary to keep ‘n’ copies of compiler for each user. It requires large storage.  If relocatable compiler is used then it is necessary to load linkage editor each time and relocate the program each time when program is execute. Thus, even if storage for n copies is saved by retaining one copy only, the storage is required for , linkage editor. Program Relocatability Relocating Logic Program + Data Relocation Information