際際滷

際際滷Share a Scribd company logo
Linker
What Is Linker ? 
combines two or more separate object programs 
and supplies the information needed to allow 
references between them
Role of linker 
Source 
Program 
Assembler 
Object 
Program 
Linker 
Executable 
Code 
Loader 
Memory 
Object 
program 
ready for 
execution
Program 
Input : 
1. P1.txt 
extern x, y, z 
2. P2.txt 
200 int x 
201 int y 
202 int z
// SIMULATION OF LINKER 
#include<iostream.h> 
#include<conio.h> 
#include<stdio.h> 
#include<string.h> 
#include<math.h> 
#include<stdlib.h> 
struct x 
{ 
char f[10]; 
}s[20],t[20],r[10];
void main() 
{ 
clrscr(); 
x o[2]={"int","float"}; 
x z[20],v[20]; 
char c,*a,*b; 
int i=0, j=0, k=0, l=0, flag=0, flag1=0, h=0, y=0, u=0; 
int m; 
FILE *p1,*p2; 
p1=fopen("p1.txt","r"); 
p2=fopen("p2.txt","r");
do 
{ 
c=fgetc(p1); 
if(c!=' '&&c!='n'&&c!=',') 
{ 
a[i]=c; 
i++; 
} 
else 
{ 
a[i]='0'; 
strcpy(s[j].f,a); 
j++; 
i=0; 
k++; } 
}while(c!=EOF);
i=0; 
j=0; 
do 
{ 
c=fgetc(p2); 
if(c!=' '&& c!='n') 
{ 
if((abs(c)>=65&&abs(c)<=90)||(abs(c)>=97&&abs(c) 
<=122)) 
{ 
a[i]=c; //insert characters e.g.int x 
i++; 
flag=1; 
}
else 
{ 
b[h]=c; //insert digits e.g. 200 
h++; 
flag1=1; 
} 
} 
else 
{ 
if(flag==1) //For characters 
{ 
a[i]='0'; 
strcpy(t[j].f,a); 
j++; 
i=0; l++; //counter
} 
if(flag1==1) // For Digits 
{ 
b[h]='0'; 
strcpy(r[y].f,b); 
y++; 
h=0; 
u++; //counter 
} 
} 
}while(c!=EOF); 
h=0;
for(i=0;i<l;i++) 
{ 
flag=0; 
for(j=0;j<2;j++) //for characters 
{ 
if(strcmp(t[i].f,o[j].f)==0||strcmp(t[i].f,"")==0) 
{ 
flag=1; 
} 
} 
if(flag==0) 
{ 
strcpy(v[h].f,t[i].f ); 
h++; 
} }
l=0; 
for(i=0;i<u;i++) //for digits 
{ 
if(strcmp(r[i].f,"")!=0) 
{ 
strcpy(z[l].f,r[i].f ); 
l++; 
} 
} 
cout<<"n***After Linking****n"; 
flag=0; 
l=0;
for(i=0;i<k;i++) 
{ 
flag=0; 
for(j=0;j<h;j++) 
{ 
if(strcmp(s[i].f,v[j].f)==0) 
flag=1; 
} 
if(flag==1) 
{ 
m=atoi(z[l].f)+400; 
cout<<s[i].f<<" "<<"p1"<<" "<<m<<"n"; 
l++; 
}
} 
fclose(p1); 
fclose(p2); 
getch(); 
}
P1.txt 
extern x, y, z; 
P2.txt 
200 int x 
201 int y 
202 int z 
After Linking 
x p1 600 
y p1 601 
z p1 602
Linker
Ad

Recommended

Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2
Dr. Loganathan R
Pruebabfs
Pruebabfs
Jorge
Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3
Dr. Loganathan R
ush1.doc
ush1.doc
student859711
contoh Program C++ tentang fungsi for
contoh Program C++ tentang fungsi for
M Fahmi Ansori
C Program : Sorting : Bubble,
C Program : Sorting : Bubble,
Meita Jayani
Kelompok 2.6
Kelompok 2.6
fiqriany1300018072
Scanfill polygon
Scanfill polygon
Sonia Pahuja
Program to remove Left factoring
Program to remove Left factoring
Shraddha Patel
listing output program C
listing output program C
AdjievanGestu
Python codigo graficas
Python codigo graficas
Brayan Kalaka
Tablas hash (Rub辿n Ndong Obiang)
Tablas hash (Rub辿n Ndong Obiang)
edi.euitio
Heep implementation in c
Heep implementation in c
HapPy SumOn
Kelompok 2.6
Kelompok 2.6
1300018075
(Meta 4) ejemplo calcular la mitad de un numero dev c++
(Meta 4) ejemplo calcular la mitad de un numero dev c++
Eli Diaz
Infix prefix postfix expression -conversion
Infix prefix postfix expression -conversion
Syed Mustafa
Corridas de los programas
Corridas de los programas
Xavi Devaluado
Oopsprc1d
Oopsprc1d
Ankit Dubey
Nested micro
Nested micro
Satyamevjayte Haxor
Lessons from life_2
Lessons from life_2
Mir Majid
ash
ash
SeongJae Park
Let the contribution begin (EST futures)
Let the contribution begin (EST futures)
SeongJae Park

More Related Content

What's hot (18)

C Program : Sorting : Bubble,
C Program : Sorting : Bubble,
Meita Jayani
Kelompok 2.6
Kelompok 2.6
fiqriany1300018072
Scanfill polygon
Scanfill polygon
Sonia Pahuja
Program to remove Left factoring
Program to remove Left factoring
Shraddha Patel
listing output program C
listing output program C
AdjievanGestu
Python codigo graficas
Python codigo graficas
Brayan Kalaka
Tablas hash (Rub辿n Ndong Obiang)
Tablas hash (Rub辿n Ndong Obiang)
edi.euitio
Heep implementation in c
Heep implementation in c
HapPy SumOn
Kelompok 2.6
Kelompok 2.6
1300018075
(Meta 4) ejemplo calcular la mitad de un numero dev c++
(Meta 4) ejemplo calcular la mitad de un numero dev c++
Eli Diaz
Infix prefix postfix expression -conversion
Infix prefix postfix expression -conversion
Syed Mustafa
Corridas de los programas
Corridas de los programas
Xavi Devaluado
Oopsprc1d
Oopsprc1d
Ankit Dubey
C Program : Sorting : Bubble,
C Program : Sorting : Bubble,
Meita Jayani
Scanfill polygon
Scanfill polygon
Sonia Pahuja
Program to remove Left factoring
Program to remove Left factoring
Shraddha Patel
listing output program C
listing output program C
AdjievanGestu
Python codigo graficas
Python codigo graficas
Brayan Kalaka
Tablas hash (Rub辿n Ndong Obiang)
Tablas hash (Rub辿n Ndong Obiang)
edi.euitio
Heep implementation in c
Heep implementation in c
HapPy SumOn
Kelompok 2.6
Kelompok 2.6
1300018075
(Meta 4) ejemplo calcular la mitad de un numero dev c++
(Meta 4) ejemplo calcular la mitad de un numero dev c++
Eli Diaz
Infix prefix postfix expression -conversion
Infix prefix postfix expression -conversion
Syed Mustafa
Corridas de los programas
Corridas de los programas
Xavi Devaluado

Viewers also liked (20)

Nested micro
Nested micro
Satyamevjayte Haxor
Lessons from life_2
Lessons from life_2
Mir Majid
ash
ash
SeongJae Park
Let the contribution begin (EST futures)
Let the contribution begin (EST futures)
SeongJae Park
AOSP 貉碁Μ觀一 蠍 dev festx korea 2012 presentation
AOSP 貉碁Μ觀一 蠍 dev festx korea 2012 presentation
SeongJae Park
Porting golang development environment developed with golang
Porting golang development environment developed with golang
SeongJae Park
Assembler
Assembler
Vaibhav Bajaj
Unit 3 assembler and processor
Unit 3 assembler and processor
Abha Damani
Use case diagrams
Use case diagrams
Mir Majid
sCode optimization
sCode optimization
Satyamevjayte Haxor
Let the contribution begin
Let the contribution begin
SeongJae Park
Patterns
Patterns
Satyamevjayte Haxor
Keyword Presentation
Keyword Presentation
Satyamevjayte Haxor
Deep dark side of git - prologue
Deep dark side of git - prologue
SeongJae Park
gcma: guaranteed contiguous memory allocator
gcma: guaranteed contiguous memory allocator
SeongJae Park
(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi
SeongJae Park
DO YOU WANT TO USE A VCS
DO YOU WANT TO USE A VCS
SeongJae Park
Git inter-snapshot public
Git inter-snapshot public
SeongJae Park
Class Outlier Mining
Class Outlier Mining
Motaz Saad
Experimental android hacking using reflection
Experimental android hacking using reflection
SeongJae Park
Lessons from life_2
Lessons from life_2
Mir Majid
Let the contribution begin (EST futures)
Let the contribution begin (EST futures)
SeongJae Park
AOSP 貉碁Μ觀一 蠍 dev festx korea 2012 presentation
AOSP 貉碁Μ觀一 蠍 dev festx korea 2012 presentation
SeongJae Park
Porting golang development environment developed with golang
Porting golang development environment developed with golang
SeongJae Park
Unit 3 assembler and processor
Unit 3 assembler and processor
Abha Damani
Use case diagrams
Use case diagrams
Mir Majid
Let the contribution begin
Let the contribution begin
SeongJae Park
Deep dark side of git - prologue
Deep dark side of git - prologue
SeongJae Park
gcma: guaranteed contiguous memory allocator
gcma: guaranteed contiguous memory allocator
SeongJae Park
(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi
SeongJae Park
DO YOU WANT TO USE A VCS
DO YOU WANT TO USE A VCS
SeongJae Park
Git inter-snapshot public
Git inter-snapshot public
SeongJae Park
Class Outlier Mining
Class Outlier Mining
Motaz Saad
Experimental android hacking using reflection
Experimental android hacking using reflection
SeongJae Park
Ad

More from Satyamevjayte Haxor (14)

Processes and threads
Processes and threads
Satyamevjayte Haxor
Uml class Diagram
Uml class Diagram
Satyamevjayte Haxor
Uml Common Mechanism
Uml Common Mechanism
Satyamevjayte Haxor
Types and roles
Types and roles
Satyamevjayte Haxor
States machine
States machine
Satyamevjayte Haxor
What is symbol table?
What is symbol table?
Satyamevjayte Haxor
Lexical
Lexical
Satyamevjayte Haxor
Single Pass Assembler
Single Pass Assembler
Satyamevjayte Haxor
Multiplier control unit
Multiplier control unit
Satyamevjayte Haxor
Control unit design
Control unit design
Satyamevjayte Haxor
Direct linking loaders
Direct linking loaders
Satyamevjayte Haxor
Two pass Assembler
Two pass Assembler
Satyamevjayte Haxor
Compilers
Compilers
Satyamevjayte Haxor
Linking in MS-Dos System
Linking in MS-Dos System
Satyamevjayte Haxor
Ad

Linker

  • 2. What Is Linker ? combines two or more separate object programs and supplies the information needed to allow references between them
  • 3. Role of linker Source Program Assembler Object Program Linker Executable Code Loader Memory Object program ready for execution
  • 4. Program Input : 1. P1.txt extern x, y, z 2. P2.txt 200 int x 201 int y 202 int z
  • 5. // SIMULATION OF LINKER #include<iostream.h> #include<conio.h> #include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> struct x { char f[10]; }s[20],t[20],r[10];
  • 6. void main() { clrscr(); x o[2]={"int","float"}; x z[20],v[20]; char c,*a,*b; int i=0, j=0, k=0, l=0, flag=0, flag1=0, h=0, y=0, u=0; int m; FILE *p1,*p2; p1=fopen("p1.txt","r"); p2=fopen("p2.txt","r");
  • 7. do { c=fgetc(p1); if(c!=' '&&c!='n'&&c!=',') { a[i]=c; i++; } else { a[i]='0'; strcpy(s[j].f,a); j++; i=0; k++; } }while(c!=EOF);
  • 8. i=0; j=0; do { c=fgetc(p2); if(c!=' '&& c!='n') { if((abs(c)>=65&&abs(c)<=90)||(abs(c)>=97&&abs(c) <=122)) { a[i]=c; //insert characters e.g.int x i++; flag=1; }
  • 9. else { b[h]=c; //insert digits e.g. 200 h++; flag1=1; } } else { if(flag==1) //For characters { a[i]='0'; strcpy(t[j].f,a); j++; i=0; l++; //counter
  • 10. } if(flag1==1) // For Digits { b[h]='0'; strcpy(r[y].f,b); y++; h=0; u++; //counter } } }while(c!=EOF); h=0;
  • 11. for(i=0;i<l;i++) { flag=0; for(j=0;j<2;j++) //for characters { if(strcmp(t[i].f,o[j].f)==0||strcmp(t[i].f,"")==0) { flag=1; } } if(flag==0) { strcpy(v[h].f,t[i].f ); h++; } }
  • 12. l=0; for(i=0;i<u;i++) //for digits { if(strcmp(r[i].f,"")!=0) { strcpy(z[l].f,r[i].f ); l++; } } cout<<"n***After Linking****n"; flag=0; l=0;
  • 13. for(i=0;i<k;i++) { flag=0; for(j=0;j<h;j++) { if(strcmp(s[i].f,v[j].f)==0) flag=1; } if(flag==1) { m=atoi(z[l].f)+400; cout<<s[i].f<<" "<<"p1"<<" "<<m<<"n"; l++; }
  • 15. P1.txt extern x, y, z; P2.txt 200 int x 201 int y 202 int z After Linking x p1 600 y p1 601 z p1 602