SlideShare uma empresa Scribd logo
1 de 8
Baixar para ler offline
System Programming
Walchand Institute of Technology
Aim:
Study of Linker
Theory:
Execution of a program written in a language L involves following steps:
1. Translation of the program
2. Linking of the program with other program needed for its execution
3. Relocation of the program to execute from the specific memory area
allocated to it
4. Loading of the program in the memory for the purpose of execution
These steps are performed by different language processors.
• Step1 by a translator for language L
• Step 2 and 3 by a linker
• Step 4 by a loader
Figure 1 contains a schematic showing step 1
Figure
The translator outputs a program called object module for the program. The linker
processes a set of object modules to produce a ready to execute program form
called binary program. The loader loads this program into the memory for the
Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur
HANDOUT#11
Execution of a program written in a language L involves following steps:
Translation of the program
Linking of the program with other program needed for its execution
Relocation of the program to execute from the specific memory area
allocated to it
Loading of the program in the memory for the purpose of execution
These steps are performed by different language processors.
Step1 by a translator for language L
and 3 by a linker
Step 4 by a loader
Figure 1 contains a schematic showing step 1-4 in the execution of a program.
Figure 1: Schematic of program execution
The translator outputs a program called object module for the program. The linker
et of object modules to produce a ready to execute program form
called binary program. The loader loads this program into the memory for the
Sunita M. Dol, CSE Dept
Page 1
Execution of a program written in a language L involves following steps:
Linking of the program with other program needed for its execution
Relocation of the program to execute from the specific memory area
Loading of the program in the memory for the purpose of execution
4 in the execution of a program.
: Schematic of program execution
The translator outputs a program called object module for the program. The linker
et of object modules to produce a ready to execute program form
called binary program. The loader loads this program into the memory for the
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 2
purpose of execution. The object modules and ready to execute program forms can
be stored in the form of files for repeated use.
Object Module:
The object module of a program contains all the information to relocate and link
the program with the other program. The object module of a program P consists of
following four components:
1. Header: The header contains the translated origin, size and execution start
address of P.
2. Program: The component contains the machine language program
corresponding to P.
3. Relocation table (RELOCTAB): this table describes IRRp (Instruction
requiring relocation). Each RELOCTAB entry contains single field:
Translated address: Translated address of an address sensitive instruction.
4. Linking table(LINKTAB): This table contains information concerning the
public definition and external references in P. Each LINKTAB entry
contains following three fields:
a. Symbol : Symbolic name
b. Type: PD/ EXT indicating whether public definition or an external
reference
c. Translated address: For public definition, this is the address of the
first memory word allocated to the symbol. For an external reference,
it is the address of the memory word that is required to contain the
address of the symbol.
Example
Consider the program P
Program P
Statement Address Code
START 500
ENTRY TOTAL
EXTRN MAX, ALPHA
READ A 500) + 09 0 540
LOOP . 501)
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 3
.
MOVER AREG, ALPHA 518) + 04 1 000
BC ANY, MAX 519) + 06 6 000
.
.
BC LT, LOOP 538) + 06 1 501
STOP 539) + 00 0 000
A DS 1 540)
TOTAL DS 541)
END
The object module of the program P contains the following information:
1. The header contains the information translated origin =500, size=42,
execution start address =500.
2. The machine language instruction is shown in above program.
3. The relocation table is follows:
Translated
Address
500
538
4. The listing table is as follows:
Symbol Type Translated address
ALPHA
MAX
A
EXT
EXT
PD
518
519
540
The symbol LOOP does not appear in the linking table. This is because it is not
declared as a public definition.
Design of a linker
Algorithm (Program Relocation)
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 4
1. program_linked_origin := <link origin> from linker command;
2. For each object module
a. t_origin := translated origin of the object module;
i. OM_size:= size of the object module
b. relocation_factor := program_linked_origin – t_origin;
c. Read the machine language program in work_area.
d. Read RELOCTAB of the object module.
e. For each entry in RELOCTAB
i. translated_address := address in the RELOCTAB entry;
ii. address_in_work_area := address of work_area +
a. translated_address –
b. t_origin;
iii. Add relocation_factor to the operand address in the word with
the address address_in_work_area.
f. program_linked_origin := program_linked_origin + OM_size;
Example
Consider program P and Q
Program P
Statement Address Code
START 500
ENTRY TOTAL
EXTRN MAX, ALPHA
READ A 500) + 09 0 540
LOOP . 501)
.
MOVER AREG, ALPHA 518) + 04 1 000
BC ANY, MAX 519) + 06 6 000
.
.
BC LT, LOOP 538) + 06 1 501
STOP 539) + 00 0 000
A DS 1 540)
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 5
TOTAL DS 541)
END
Program Q
Statement Address Code
START 200
ENTRY ALPHA
--
--
ALPHA DS 25 231) + 00 0 025
END
Let the address of work area be 300. While relocating the object module, relocation
factor = 400. Hence for the first RELOCTAB entry,
address_in_work_area=300+500-500=300. This word contains the instruction for
READ A. It is relocated by adding 400 to the operand address in it. For the
second RELOCTAB entry, address_in_work_area = 300+538-500=338. The
instruction in this word is similarly relocated by adding 400 to the operand address
in it.
Linking requirements
An external reference to a symbol ALPHA can be resolved only if ALPHA is
declared as a public definition in some object module. Using this observation as
the basis, program linking can be performed as follows: The linker processes all
object modules being linked and builds a table of all public definitions and their
load time addresses.
A name table (NTAB) is defined for use in program linking. Each entry of the
table contains the following fields:
1. Symbol: Symbolic name of an external reference or an object module.
2. Linked_address: For public definition, this field contains linked
address of symbol. For an object module it contains the linked origin of
object module.
Most information in NTAB is derived from LINKTAB entries with type = PD.
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 6
Algorithm (Program linking)
1. program_linked_origin := <link origin> from linker command.
2. For each object module
a) t_origin := translated origin of the object module;
OM_size := size of the object module
b) relocation_factor := program_linked_origin – t_origin;
c) Read the machine language program in work_area.
d) Read LINKTAB of the object module.
e) For each LINKTAB entry with type = PD
name := symbol;
linked_address := translated_address + relocation_factor;
Enter (name, linked_address) in NTAB.
f) Enter (object module name, program_linked_origin) in NTAB;
g) program_linked_origin := program_lined_origin + OM_size;
3. For each object module
a) t_origin := translated origin of the object module;
program_linked_origin := load_address from NTAB;
b) For each LINKTAB entry with type = EXT
i. address_in_work_area := address of work_area +
program_linked_origin –
<link origin> +
translated address –
t_origin;
ii. Search symbol in NTAB and copy its linked address. Add
the linked address to the operand address in the word with
the address address_in_work_area.
Example
Consider program P and Q
Program P
Statement Address Code
START 500
ENTRY TOTAL
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 7
EXTRN MAX, ALPHA
READ A 500) + 09 0 540
LOOP . 501)
.
MOVER AREG, ALPHA 518) + 04 1 000
BC ANY, MAX 519) + 06 6 000
.
.
BC LT, LOOP 538) + 06 1 501
STOP 539) + 00 0 000
A DS 1 540)
TOTAL DS 541)
END
Program Q
Statement Address Code
START 200
ENTRY ALPHA
--
--
ALPHA DS 25 231) + 00 0 025
END
The object module of the program P contains the following information:
1. The header contains the information translated origin =500, size=42,
execution start address =500.
2. The machine language instruction is shown in above program.
3. The relocation table is follows:
Translated
Address
500
538
4. The listing table is as follows:
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 8
Symbol Type Translated address
ALPHA
MAX
A
EXT
EXT
PD
518
519
540
While linking program P and Q with linked origin = 900, NTAB would contain the
following information:
symbol Linked address
P
A
Q
ALPHA
900
940
942
973
Conclusion:
Linker performs the following functions required for the execution of a program
written in a language L:
1. Linking of the program with other program needed for its execution
2. Relocation of the program to execute from the specific memory area
allocated to it
The linker processes a set of object modules, the output of the translator to produce
a ready to execute program form called binary program

Mais conteúdo relacionado

Mais procurados (20)

Handout#08
Handout#08Handout#08
Handout#08
 
Assignment1
Assignment1Assignment1
Assignment1
 
Assignment4
Assignment4Assignment4
Assignment4
 
Handout#06
Handout#06Handout#06
Handout#06
 
Handout#12
Handout#12Handout#12
Handout#12
 
Handout#09
Handout#09Handout#09
Handout#09
 
C language
C languageC language
C language
 
C programming course material
C programming course materialC programming course material
C programming course material
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
 
7 compiler lab
7 compiler lab 7 compiler lab
7 compiler lab
 
Introduction of C++ By Pawan Thakur
Introduction of C++ By Pawan ThakurIntroduction of C++ By Pawan Thakur
Introduction of C++ By Pawan Thakur
 
C programming languag for cse students
C programming languag for cse studentsC programming languag for cse students
C programming languag for cse students
 
C tutorial
C tutorialC tutorial
C tutorial
 
Phases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingPhases of the Compiler - Systems Programming
Phases of the Compiler - Systems Programming
 
Chapter2
Chapter2Chapter2
Chapter2
 
C programming notes
C programming notesC programming notes
C programming notes
 
C notes
C notesC notes
C notes
 
Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
Bcsl 031 solve assignment
 
Compiler question bank
Compiler question bankCompiler question bank
Compiler question bank
 
Programming in c
Programming in cProgramming in c
Programming in c
 

Semelhante a Handout#11

Oosd lecture unit 4 ppt introduction part
Oosd lecture unit 4 ppt introduction partOosd lecture unit 4 ppt introduction part
Oosd lecture unit 4 ppt introduction partManuSingh669370
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptxMugilvannan11
 
Overview of c++
Overview of c++Overview of c++
Overview of c++geeeeeet
 
Book management system
Book management systemBook management system
Book management systemSHARDA SHARAN
 
Chap 2 structure of c programming dti2143
Chap 2  structure of c programming dti2143Chap 2  structure of c programming dti2143
Chap 2 structure of c programming dti2143alish sha
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdfvino108206
 
Programming in c (importance of c)
Programming in c (importance of c)Programming in c (importance of c)
Programming in c (importance of c)ViswanathanS21
 
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxVigneshkumar Ponnusamy
 
Chapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdfChapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdfKirubelWondwoson1
 
linker & loader presentation in Compiler Design
linker & loader presentation in Compiler Designlinker & loader presentation in Compiler Design
linker & loader presentation in Compiler DesignAbhishekKumar117405
 
Chap 1-language processor
Chap 1-language processorChap 1-language processor
Chap 1-language processorshindept123
 
Compiler gate question key
Compiler gate question keyCompiler gate question key
Compiler gate question keyArthyR3
 

Semelhante a Handout#11 (20)

Unit 3
Unit 3Unit 3
Unit 3
 
Oosd lecture unit 4 ppt introduction part
Oosd lecture unit 4 ppt introduction partOosd lecture unit 4 ppt introduction part
Oosd lecture unit 4 ppt introduction part
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 
Overview of c++
Overview of c++Overview of c++
Overview of c++
 
Book management system
Book management systemBook management system
Book management system
 
Chap 2 structure of c programming dti2143
Chap 2  structure of c programming dti2143Chap 2  structure of c programming dti2143
Chap 2 structure of c programming dti2143
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdf
 
C PROGRAMMING p-2.pdf
C PROGRAMMING p-2.pdfC PROGRAMMING p-2.pdf
C PROGRAMMING p-2.pdf
 
Programming in c (importance of c)
Programming in c (importance of c)Programming in c (importance of c)
Programming in c (importance of c)
 
Embedded C.pptx
Embedded C.pptxEmbedded C.pptx
Embedded C.pptx
 
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptx
 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
 
Chapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdfChapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdf
 
linker & loader presentation in Compiler Design
linker & loader presentation in Compiler Designlinker & loader presentation in Compiler Design
linker & loader presentation in Compiler Design
 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
 
Chap 1-language processor
Chap 1-language processorChap 1-language processor
Chap 1-language processor
 
Unit 2 ppt
Unit 2 pptUnit 2 ppt
Unit 2 ppt
 
C++ Constructs.pptx
C++ Constructs.pptxC++ Constructs.pptx
C++ Constructs.pptx
 
Compiler gate question key
Compiler gate question keyCompiler gate question key
Compiler gate question key
 
Cp week _2.
Cp week _2.Cp week _2.
Cp week _2.
 

Mais de Sunita Milind Dol (18)

9.Joins.pdf
9.Joins.pdf9.Joins.pdf
9.Joins.pdf
 
8.Views.pdf
8.Views.pdf8.Views.pdf
8.Views.pdf
 
7. Nested Subqueries.pdf
7. Nested Subqueries.pdf7. Nested Subqueries.pdf
7. Nested Subqueries.pdf
 
6. Aggregate Functions.pdf
6. Aggregate Functions.pdf6. Aggregate Functions.pdf
6. Aggregate Functions.pdf
 
5. Basic Structure of SQL Queries.pdf
5. Basic Structure of SQL Queries.pdf5. Basic Structure of SQL Queries.pdf
5. Basic Structure of SQL Queries.pdf
 
4. DML.pdf
4. DML.pdf4. DML.pdf
4. DML.pdf
 
3. DDL.pdf
3. DDL.pdf3. DDL.pdf
3. DDL.pdf
 
2. SQL Introduction.pdf
2. SQL Introduction.pdf2. SQL Introduction.pdf
2. SQL Introduction.pdf
 
1. University Example.pdf
1. University Example.pdf1. University Example.pdf
1. University Example.pdf
 
Assignment12
Assignment12Assignment12
Assignment12
 
Assignment10
Assignment10Assignment10
Assignment10
 
Assignment9
Assignment9Assignment9
Assignment9
 
Assignment8
Assignment8Assignment8
Assignment8
 
Assignment7
Assignment7Assignment7
Assignment7
 
Assignment6
Assignment6Assignment6
Assignment6
 
Assignment5
Assignment5Assignment5
Assignment5
 
Assignment3
Assignment3Assignment3
Assignment3
 
Assignment2
Assignment2Assignment2
Assignment2
 

Último

Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 

Último (20)

Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 

Handout#11

  • 1. System Programming Walchand Institute of Technology Aim: Study of Linker Theory: Execution of a program written in a language L involves following steps: 1. Translation of the program 2. Linking of the program with other program needed for its execution 3. Relocation of the program to execute from the specific memory area allocated to it 4. Loading of the program in the memory for the purpose of execution These steps are performed by different language processors. • Step1 by a translator for language L • Step 2 and 3 by a linker • Step 4 by a loader Figure 1 contains a schematic showing step 1 Figure The translator outputs a program called object module for the program. The linker processes a set of object modules to produce a ready to execute program form called binary program. The loader loads this program into the memory for the Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur HANDOUT#11 Execution of a program written in a language L involves following steps: Translation of the program Linking of the program with other program needed for its execution Relocation of the program to execute from the specific memory area allocated to it Loading of the program in the memory for the purpose of execution These steps are performed by different language processors. Step1 by a translator for language L and 3 by a linker Step 4 by a loader Figure 1 contains a schematic showing step 1-4 in the execution of a program. Figure 1: Schematic of program execution The translator outputs a program called object module for the program. The linker et of object modules to produce a ready to execute program form called binary program. The loader loads this program into the memory for the Sunita M. Dol, CSE Dept Page 1 Execution of a program written in a language L involves following steps: Linking of the program with other program needed for its execution Relocation of the program to execute from the specific memory area Loading of the program in the memory for the purpose of execution 4 in the execution of a program. : Schematic of program execution The translator outputs a program called object module for the program. The linker et of object modules to produce a ready to execute program form called binary program. The loader loads this program into the memory for the
  • 2. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 2 purpose of execution. The object modules and ready to execute program forms can be stored in the form of files for repeated use. Object Module: The object module of a program contains all the information to relocate and link the program with the other program. The object module of a program P consists of following four components: 1. Header: The header contains the translated origin, size and execution start address of P. 2. Program: The component contains the machine language program corresponding to P. 3. Relocation table (RELOCTAB): this table describes IRRp (Instruction requiring relocation). Each RELOCTAB entry contains single field: Translated address: Translated address of an address sensitive instruction. 4. Linking table(LINKTAB): This table contains information concerning the public definition and external references in P. Each LINKTAB entry contains following three fields: a. Symbol : Symbolic name b. Type: PD/ EXT indicating whether public definition or an external reference c. Translated address: For public definition, this is the address of the first memory word allocated to the symbol. For an external reference, it is the address of the memory word that is required to contain the address of the symbol. Example Consider the program P Program P Statement Address Code START 500 ENTRY TOTAL EXTRN MAX, ALPHA READ A 500) + 09 0 540 LOOP . 501)
  • 3. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 3 . MOVER AREG, ALPHA 518) + 04 1 000 BC ANY, MAX 519) + 06 6 000 . . BC LT, LOOP 538) + 06 1 501 STOP 539) + 00 0 000 A DS 1 540) TOTAL DS 541) END The object module of the program P contains the following information: 1. The header contains the information translated origin =500, size=42, execution start address =500. 2. The machine language instruction is shown in above program. 3. The relocation table is follows: Translated Address 500 538 4. The listing table is as follows: Symbol Type Translated address ALPHA MAX A EXT EXT PD 518 519 540 The symbol LOOP does not appear in the linking table. This is because it is not declared as a public definition. Design of a linker Algorithm (Program Relocation)
  • 4. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 4 1. program_linked_origin := <link origin> from linker command; 2. For each object module a. t_origin := translated origin of the object module; i. OM_size:= size of the object module b. relocation_factor := program_linked_origin – t_origin; c. Read the machine language program in work_area. d. Read RELOCTAB of the object module. e. For each entry in RELOCTAB i. translated_address := address in the RELOCTAB entry; ii. address_in_work_area := address of work_area + a. translated_address – b. t_origin; iii. Add relocation_factor to the operand address in the word with the address address_in_work_area. f. program_linked_origin := program_linked_origin + OM_size; Example Consider program P and Q Program P Statement Address Code START 500 ENTRY TOTAL EXTRN MAX, ALPHA READ A 500) + 09 0 540 LOOP . 501) . MOVER AREG, ALPHA 518) + 04 1 000 BC ANY, MAX 519) + 06 6 000 . . BC LT, LOOP 538) + 06 1 501 STOP 539) + 00 0 000 A DS 1 540)
  • 5. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 5 TOTAL DS 541) END Program Q Statement Address Code START 200 ENTRY ALPHA -- -- ALPHA DS 25 231) + 00 0 025 END Let the address of work area be 300. While relocating the object module, relocation factor = 400. Hence for the first RELOCTAB entry, address_in_work_area=300+500-500=300. This word contains the instruction for READ A. It is relocated by adding 400 to the operand address in it. For the second RELOCTAB entry, address_in_work_area = 300+538-500=338. The instruction in this word is similarly relocated by adding 400 to the operand address in it. Linking requirements An external reference to a symbol ALPHA can be resolved only if ALPHA is declared as a public definition in some object module. Using this observation as the basis, program linking can be performed as follows: The linker processes all object modules being linked and builds a table of all public definitions and their load time addresses. A name table (NTAB) is defined for use in program linking. Each entry of the table contains the following fields: 1. Symbol: Symbolic name of an external reference or an object module. 2. Linked_address: For public definition, this field contains linked address of symbol. For an object module it contains the linked origin of object module. Most information in NTAB is derived from LINKTAB entries with type = PD.
  • 6. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 6 Algorithm (Program linking) 1. program_linked_origin := <link origin> from linker command. 2. For each object module a) t_origin := translated origin of the object module; OM_size := size of the object module b) relocation_factor := program_linked_origin – t_origin; c) Read the machine language program in work_area. d) Read LINKTAB of the object module. e) For each LINKTAB entry with type = PD name := symbol; linked_address := translated_address + relocation_factor; Enter (name, linked_address) in NTAB. f) Enter (object module name, program_linked_origin) in NTAB; g) program_linked_origin := program_lined_origin + OM_size; 3. For each object module a) t_origin := translated origin of the object module; program_linked_origin := load_address from NTAB; b) For each LINKTAB entry with type = EXT i. address_in_work_area := address of work_area + program_linked_origin – <link origin> + translated address – t_origin; ii. Search symbol in NTAB and copy its linked address. Add the linked address to the operand address in the word with the address address_in_work_area. Example Consider program P and Q Program P Statement Address Code START 500 ENTRY TOTAL
  • 7. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 7 EXTRN MAX, ALPHA READ A 500) + 09 0 540 LOOP . 501) . MOVER AREG, ALPHA 518) + 04 1 000 BC ANY, MAX 519) + 06 6 000 . . BC LT, LOOP 538) + 06 1 501 STOP 539) + 00 0 000 A DS 1 540) TOTAL DS 541) END Program Q Statement Address Code START 200 ENTRY ALPHA -- -- ALPHA DS 25 231) + 00 0 025 END The object module of the program P contains the following information: 1. The header contains the information translated origin =500, size=42, execution start address =500. 2. The machine language instruction is shown in above program. 3. The relocation table is follows: Translated Address 500 538 4. The listing table is as follows:
  • 8. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 8 Symbol Type Translated address ALPHA MAX A EXT EXT PD 518 519 540 While linking program P and Q with linked origin = 900, NTAB would contain the following information: symbol Linked address P A Q ALPHA 900 940 942 973 Conclusion: Linker performs the following functions required for the execution of a program written in a language L: 1. Linking of the program with other program needed for its execution 2. Relocation of the program to execute from the specific memory area allocated to it The linker processes a set of object modules, the output of the translator to produce a ready to execute program form called binary program