SlideShare a Scribd company logo
1 of 13
Introduction to Linker
Prepared by:-
Name - Rahul Dhiman
Rollno - 14508
Sem - 4th sem ( 2nd year)
Branch - Computer Science & Engg.
WHAT IS LINKER ?
 Linker is a system software.
 Linker is also referred as link editor.
 It links the object (.obj) files generated by the assembler.
 It combines those object files into single excecutable file , library file, or
another object file.
WHY WE NEED LINKERS ?
 Often in a large program , you will separate out the code into multiple files
to keep related functions together.
 Each of these multiple files can be compiled into object code.
 But our final goal is to create a single executable file.
 There must be a way to combine each of these object files into a single
executable .We call this linking.
 Linking is process that is carried out by the linker.
USE OF LINKER IN COMPILATION:-
A.c B.c
A.obj B.obj
Linker
Executable File(.exe)
 Linker’s use occurs at the very end of
the compilation right after the
assembler.
 Here A.c and B.c are the two source
code files for project (say) .
 After compilation of these two files ,the
object files obtained are A.obj and
B.obj.
 Now to get a single executable file ,we
pass these object files to linker or link
editor.
Library
TYPES OF LINKING:-
 Linker takes the object code generated by the compiler/assembler ,and
links it against a c library (and /or libgcc.a or whatever link library you
provide).This can be done in two ways :-
a) Static linking
b) Dynamic linking
STATIC LINKING:-
 When linking statically , linker invocation is done during the build process
i.e just after the compiler/assembler run.
 linker takes the object code and checks it for unresolved references
if any.
 Linker checks if it can resolve these unresolved refrences from the available
libraries (including user created libraries also).
 It adds the binary code from these libraries to the executable. After this
executable is complete.
 In this linking ,executable file is quiet large both on disk and memory
because the code from the libraries is duplicated over and over.
DYNAMIC LINKING:-
 When linking dynamically, linker is invoked during the loading of an
executable.
 It also checks the object code for unresolved references.
 The unresolved references are resolved against the libraries currently
present in the system.
 In dynamic linking , the on-disk executable file is smaller in size and allows
for in-memory space saving strategies such as shared libraries.
 Executable depends on the presence of libraries it references . If a system
doesn’t have those libraries executable can’t run.
OVERVIEW OF MAKING A EXECUTABLE
FILE:-
 First compiler takes the source code files of your project written in
c / c++ etc.
 Compiler compiles these multiple into their corresponding
assembly language files followed by extension (.asm).
 Assembler converts the assembly language code file into binary
code file to which we referred as object file.
 After the assembler linker comes and does it’s work in two
steps :- a ) Symbol addressing
b ) Resolve addressing
 After linker has done it’s work , a new file with extension (.exe)
is created which is the executable file of your project.
Compiler
Source code
files
Assembler
Linker
Executable
file
LINKER USED IN OPERATING SYSTEM:-
 In computing , a dynamic linker is the part of an operating system.
 It loads and links the shared libraries needed by an executable when it is
executed.
 Dynamic linker functionality and implementation depends upon two
factors : -
 Specific operating system ( like windows , linux , Mac etc. )
 Executable format
 In Ubuntu operating system linker used is a standalone linker and also
referred via “ld”. On Unix-like systems, the linker is typically invoked with
the ld command.
HOW TO SAVE INTERMEDIATE FILES IN BETWEEN
COMPILATION OF A PROGRAM ?
 Suppose you have created a C program say “hello.c”.
 When you compile this program in Ubuntu using gcc compiler by typing
“gcc hello.c” .
 Without saving it’s object code ,assembly code and binary code files , it’ll
directly create a executable file (ELF for GCC).
 To save those intermediate files you can use the command
“gcc –Wall –save-temps hello.c –o hello”.
 Then you can check that the intermediate files are created in the same
directory .
THANK YOU ALL

More Related Content

What's hot

1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of c
Harish Kumawat
 
C and its errors
C and its errorsC and its errors
C and its errors
Junaid Raja
 

What's hot (20)

Language processing activity
Language processing activityLanguage processing activity
Language processing activity
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
 
Loaders
LoadersLoaders
Loaders
 
Steps for c program execution
Steps for c program executionSteps for c program execution
Steps for c program execution
 
Linkers And Loaders
Linkers And LoadersLinkers And Loaders
Linkers And Loaders
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
Introduction to c++ ppt
Introduction to c++ pptIntroduction to c++ ppt
Introduction to c++ ppt
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3
 
Language processors
Language processorsLanguage processors
Language processors
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming )
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
 
Ch 4 linker loader
Ch 4 linker loaderCh 4 linker loader
Ch 4 linker loader
 
CS3251-_PIC
CS3251-_PICCS3251-_PIC
CS3251-_PIC
 
Unit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionUnit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introduction
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of c
 
C and its errors
C and its errorsC and its errors
C and its errors
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Language translator
Language translatorLanguage translator
Language translator
 

Viewers also liked

Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loader
babyparul
 
Prims Algorithm
Prims AlgorithmPrims Algorithm
Prims Algorithm
Sriram Raj
 
Minimum Spanning Tree
Minimum Spanning TreeMinimum Spanning Tree
Minimum Spanning Tree
zhaokatherine
 

Viewers also liked (17)

Loaders
LoadersLoaders
Loaders
 
Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loader
 
minimum spanning trees Algorithm
minimum spanning trees Algorithm minimum spanning trees Algorithm
minimum spanning trees Algorithm
 
Greedy minimum spanning tree- prim's algorithm
Greedy minimum spanning tree- prim's algorithmGreedy minimum spanning tree- prim's algorithm
Greedy minimum spanning tree- prim's algorithm
 
Prims Algorithm
Prims AlgorithmPrims Algorithm
Prims Algorithm
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Minimum spanning Tree
Minimum spanning TreeMinimum spanning Tree
Minimum spanning Tree
 
Minimum Spanning Tree
Minimum Spanning TreeMinimum Spanning Tree
Minimum Spanning Tree
 
My presentation minimum spanning tree
My presentation minimum spanning treeMy presentation minimum spanning tree
My presentation minimum spanning tree
 
Direct linking loaders
Direct linking loadersDirect linking loaders
Direct linking loaders
 
Loader
LoaderLoader
Loader
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
 
Assembly: before and after
Assembly: before and afterAssembly: before and after
Assembly: before and after
 
Dynamic Linker
Dynamic LinkerDynamic Linker
Dynamic Linker
 
Loaders
LoadersLoaders
Loaders
 
Connectors and-linkers
Connectors and-linkersConnectors and-linkers
Connectors and-linkers
 
Kernel (OS)
Kernel (OS)Kernel (OS)
Kernel (OS)
 

Similar to Linkers

Rolling Your Own Embedded Linux Distribution
Rolling  Your  Own  Embedded  Linux  DistributionRolling  Your  Own  Embedded  Linux  Distribution
Rolling Your Own Embedded Linux Distribution
Emanuele Bonanni
 
Introduction to Software Build Technology
Introduction to Software Build TechnologyIntroduction to Software Build Technology
Introduction to Software Build Technology
Philip Johnson
 
101 2.3 manage shared libraries
101 2.3 manage shared libraries101 2.3 manage shared libraries
101 2.3 manage shared libraries
Acácio Oliveira
 
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
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdp
Mohd Arif
 

Similar to Linkers (20)

Linking in MS-Dos System
Linking in MS-Dos SystemLinking in MS-Dos System
Linking in MS-Dos System
 
Advanced c programming in Linux
Advanced c programming in Linux Advanced c programming in Linux
Advanced c programming in Linux
 
Linkers in compiler
Linkers in compilerLinkers in compiler
Linkers in compiler
 
C++ shared libraries and loading
C++ shared libraries and loadingC++ shared libraries and loading
C++ shared libraries and loading
 
Hm system programming class 1
Hm system programming class 1Hm system programming class 1
Hm system programming class 1
 
Loaders complete
Loaders completeLoaders complete
Loaders complete
 
Rolling Your Own Embedded Linux Distribution
Rolling  Your  Own  Embedded  Linux  DistributionRolling  Your  Own  Embedded  Linux  Distribution
Rolling Your Own Embedded Linux Distribution
 
Angular meteor presentation
Angular meteor presentationAngular meteor presentation
Angular meteor presentation
 
Introduction to Software Build Technology
Introduction to Software Build TechnologyIntroduction to Software Build Technology
Introduction to Software Build Technology
 
Compilation in c
Compilation in cCompilation in c
Compilation in c
 
Consuming and Creating Libraries in C++
Consuming and Creating Libraries in C++Consuming and Creating Libraries in C++
Consuming and Creating Libraries in C++
 
Lightning web components
Lightning web components Lightning web components
Lightning web components
 
Build process ppt.pptx
Build process ppt.pptxBuild process ppt.pptx
Build process ppt.pptx
 
Address Binding Scheme
Address Binding SchemeAddress Binding Scheme
Address Binding Scheme
 
101 2.3 manage shared libraries
101 2.3 manage shared libraries101 2.3 manage shared libraries
101 2.3 manage shared libraries
 
.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologies
 
Linux internals v4
Linux internals v4Linux internals v4
Linux internals v4
 
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
 
From gcc to the autotools
From gcc to the autotoolsFrom gcc to the autotools
From gcc to the autotools
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdp
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 

Linkers

  • 1. Introduction to Linker Prepared by:- Name - Rahul Dhiman Rollno - 14508 Sem - 4th sem ( 2nd year) Branch - Computer Science & Engg.
  • 2. WHAT IS LINKER ?  Linker is a system software.  Linker is also referred as link editor.  It links the object (.obj) files generated by the assembler.  It combines those object files into single excecutable file , library file, or another object file.
  • 3. WHY WE NEED LINKERS ?  Often in a large program , you will separate out the code into multiple files to keep related functions together.  Each of these multiple files can be compiled into object code.  But our final goal is to create a single executable file.  There must be a way to combine each of these object files into a single executable .We call this linking.  Linking is process that is carried out by the linker.
  • 4. USE OF LINKER IN COMPILATION:- A.c B.c A.obj B.obj Linker Executable File(.exe)  Linker’s use occurs at the very end of the compilation right after the assembler.  Here A.c and B.c are the two source code files for project (say) .  After compilation of these two files ,the object files obtained are A.obj and B.obj.  Now to get a single executable file ,we pass these object files to linker or link editor. Library
  • 5. TYPES OF LINKING:-  Linker takes the object code generated by the compiler/assembler ,and links it against a c library (and /or libgcc.a or whatever link library you provide).This can be done in two ways :- a) Static linking b) Dynamic linking
  • 6. STATIC LINKING:-  When linking statically , linker invocation is done during the build process i.e just after the compiler/assembler run.  linker takes the object code and checks it for unresolved references if any.  Linker checks if it can resolve these unresolved refrences from the available libraries (including user created libraries also).  It adds the binary code from these libraries to the executable. After this executable is complete.  In this linking ,executable file is quiet large both on disk and memory because the code from the libraries is duplicated over and over.
  • 7. DYNAMIC LINKING:-  When linking dynamically, linker is invoked during the loading of an executable.  It also checks the object code for unresolved references.  The unresolved references are resolved against the libraries currently present in the system.  In dynamic linking , the on-disk executable file is smaller in size and allows for in-memory space saving strategies such as shared libraries.  Executable depends on the presence of libraries it references . If a system doesn’t have those libraries executable can’t run.
  • 8. OVERVIEW OF MAKING A EXECUTABLE FILE:-  First compiler takes the source code files of your project written in c / c++ etc.  Compiler compiles these multiple into their corresponding assembly language files followed by extension (.asm).  Assembler converts the assembly language code file into binary code file to which we referred as object file.  After the assembler linker comes and does it’s work in two steps :- a ) Symbol addressing b ) Resolve addressing  After linker has done it’s work , a new file with extension (.exe) is created which is the executable file of your project. Compiler Source code files Assembler Linker Executable file
  • 9.
  • 10.
  • 11. LINKER USED IN OPERATING SYSTEM:-  In computing , a dynamic linker is the part of an operating system.  It loads and links the shared libraries needed by an executable when it is executed.  Dynamic linker functionality and implementation depends upon two factors : -  Specific operating system ( like windows , linux , Mac etc. )  Executable format  In Ubuntu operating system linker used is a standalone linker and also referred via “ld”. On Unix-like systems, the linker is typically invoked with the ld command.
  • 12. HOW TO SAVE INTERMEDIATE FILES IN BETWEEN COMPILATION OF A PROGRAM ?  Suppose you have created a C program say “hello.c”.  When you compile this program in Ubuntu using gcc compiler by typing “gcc hello.c” .  Without saving it’s object code ,assembly code and binary code files , it’ll directly create a executable file (ELF for GCC).  To save those intermediate files you can use the command “gcc –Wall –save-temps hello.c –o hello”.  Then you can check that the intermediate files are created in the same directory .