Linkerandloader

Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

Linker and loader

Linker and Loader are the utility programs that plays a major role in the
execution of a program. The Source code of a program passes through
compiler, assembler, linker, loader in the respective order, before execution.
On the one hand, where the linker intakes the object codes generated by
the assembler and combine them to generate the executable module.
On the other hands, the loader loads this executable module to the main
memory for execution.

1
Linker and loader

2
C program compilation process

The high-level language is converted into binary language in various phases. A


compiler is a program that converts high-level language to assembly language.
Similarly, an assembler is a program that converts the assembly language to
machine-level language.
Let us first understand how a program, using C compiler, is executed on a host
machine.

The C compiler, compiles the program and translates it to assembly program (low-level language).
An assembler then translates the assembly program into machine code (object)
A linker tool is used to link all the parts of the program together for execution (executable machine code).
A loader loads all of them into memory and then the program is executed.
3
Linker

The Assembler generates the object code of a source program and hands it
over to the linker. The linker takes this object code and generates the
executable code for the program, and hand it over to the Loader.

The high-level language, programs have some built-in libraries and header
files. The source program may contain some library functions whose
definition are stored in the built-in libraries. The linker links these function
to the built-in libraries. In case the built-in libraries are not found it informs
to the compiler, and the compiler then generates the error.

4
Sometimes the large programs are divided into the subprograms which are
called modules. Now when these modules are compiled and assembled, the
object modules of the source program are generated. The linker has the
responsibility of combining/linking all the object modules to generate a
single executable file of the source program.

5
We have two types of linkers:

Linkage Editor: It is a linker that generates the relocatable, executable


module.

Dynamic Linker: It defers/postpones the linkage of some external


modules until the load module/executable module is generated. Here,
linking is done during load time or run time.

6
Loader

As the program that has to be executed currently must reside in the main
memory of the computer. It is the responsibility of the loader, a program in
an operating system, to load the executable file/module of a program,
generated by the linker, to the main memory for execution. It allocates the
memory space to the executable module in main memory.

There are three kinds of loader:


Absolute loader
Bootstrap loader
Relocatable loader
7
Absolute Loader

The operation of absolute loader is very simple. The object code is loaded to
specified locations in the memory. At the end the loader jumps to the specified
address to begin execution of the loaded program. The advantage of
absolute loader is simple and efficient. But the disadvantages are,the need
for programmer to specify the actual address, and, difficult to use subroutine
libraries.

Bootstrap Loader
When a computer is first turned on or restarted, a special type of absolute loader, called
bootstrap loader is executed. This bootstrap loads the first program to be run by the
computer--usually an operating system. The bootstrap itself begins at address 0. It loads
the OS starting address 0x80.No header record or control information, the object code
is consecutive bytes of memory.

8
Relocation Loader
The concept of program relocation is, the execution of the object
program using any part of the available and sufficient memory. The
object program is loaded into memory wherever there is room for it. The
actual starting address of the object program is not known until load
time. Relocation provides the efficient sharing of the machine with
larger memory and when several independent programs are to be run
together. It also supports the use of subroutine libraries efficiently.
Loaders that allow for program relocation are called relocating loaders or
relative loaders.

9
LINKER LOADER
1.The main function of Linker is to generate Whereas main objective of Loader is to
executable files. executable files to main memory.
2. The linker takes input of object code The loader takes input of executable files
generated by compiler/assembler. generated by linker.
3. Linking can be defined as process of Loading can be defined as process of
combining various pieces of codes and loading executable codes to main memory
source code to obtain executable code. for further execution.
4. Linker is of 2 types: Linkage Editor and Loader is of 3 types: Absolute loading,
Dynamic Linker. Relocatable loading and Dynamic run-time
loading.
5. Another use of linker is to combine all It helps in allocating the address to
object modules. executable codes/files.
6. Linker is also responsible for arranging Loader is also responsible for adjusting
objects in program’s address space. references which are used within the
program.
10
Generation of programming language

11
12
Programming languages have been developed over the year in a phased manner. Each phase
of developed has made the programming language more user-friendly, easier to use and
more powerful. Each phase of improved made in the development of the programming
languages can be referred to as a generation. The programming language in terms of their
performance reliability and robustness can be grouped into five different generations,

13
1. First Generation Language (Machine language):1GL

The first generation programming language is also called low-level programming


language because they were used to program the computer system at a very low
level of abstraction. i.e. at the machine level. The machine language also referred
to as the native language of the computer system is the first generation
programming language. In the machine language, a programmer only deals with
a binary number.
Advantages of first generation language
1. They are translation free and can be directly executed by the computers.
2. The programs written in these languages are executed very speedily and
efficiently by the CPU of the computer system.
3. The programs written in these languages utilize the memory in an efficient
manner because it is possible to keep track of each bit of data.
14
2. Second Generation language (Assembly Language):2GL
The second generation programming language also belongs to the
category of low-level- programming language. The second generation
language comprises assembly languages that use the concept of
mnemonics for the writing program. In the assembly language, symbolic
names are used to represent the opcode and the operand part of the
instruction.
Advantages of second generation language
1. It is easy to develop understand and modify the program developed in these
languages are compared to those developed in the first generation programming
language.
2. The programs written in these languages are less prone to errors and therefore
can be maintained with a great case.
15
Third Generation languages (High-Level Languages):3GL

The third generation programming languages were designed to overcome


the various limitations of the first and second generation programming
languages. The languages of the third and later generation are
considered as a high-level language because they enable the
programmer to concentrate only on the logic of the programs without
considering the internal architecture of the computer system.

16
Advantages of third generation programming language

It is easy to develop, learn and understand the program.


As the program written in these languages are less prone to errors they
are easy to maintain.
The program written in these languages can be developed in very less
time as compared to the first and second generation language.

Examples: FORTRAN, ALGOL, COBOL, C++, C

17
Fourth generation language (Very High-level Languages):4GL

The languages of this generation were considered as very high-level programming languages
Each of the programming language generations aims to provide a higher level of
abstraction of the internal computer hardware details, making the language more
programmer-friendly, powerful, and versatile. While the definition of 4GL has changed over
time, it can be typified by operating more with large collections of information at once
rather than focusing on just bits and bytes.
The fourth generation programming languages were designed and developed to reduce the
time, cost and effort needed to develop different types of software applications.
Languages claimed to be 4GL may include support for database management, report
generation, mathematical optimization, GUI development, or web development.

18
A number of different types of 4GLs exist:
•Report-generator programming languages take a description of the data format and the
report to generate and from that they either generate the required report directly or they
generate a program to generate the report.
•Similarly, forms generators manage online interactions with the application system users
or generate programs to do so.
•More ambitious 4GLs (sometimes termed fourth generation environments) attempt to
automatically generate whole systems from the outputs of CASE tools, specifications of
screens and reports, and possibly also the specification of some additional processing
logic.
Data management 4GLs such as SAS, SPSS, and Stata provide sophisticated coding
commands for data manipulation, file reshaping, case selection, and data
documentation in the preparation of data for statistical analysis and reporting.
19
Advantages of fourth generation languages
1. These programming languages allow the efficient use of data by
implementing the various database.
2. They require less time, cost and effort to develop different types of
software applications.
3. The program developed in these languages are highly portable as
compared to the programs developed in the languages of other
generation.

20
Fifth generation language (Artificial Intelligence Language):5GL

The programming languages of this generation mainly focus on constraint


programming. The major fields in which the fifth generation
programming language are employed are Artificial Intelligence and
Artificial Neural Networks
Advantages of fifth generation languages
1.These languages can be used to query the database in a fast and efficient
manner.
2. In this generation of language, the user can communicate with the
computer system in a simple and an easy manner.
Examples: mercury, prolog, OPS5

21
What Is the Difference Between 3GLs and 4GLs?

❑ 3GLs (Third-generation programming languages) are categorized as procedural languages,


because the program instructions are procedure-oriented and contain a series of steps that
not only tell the computer what to do, but how to do it. On the other hand, 4GLs (Fourth-
generation programming languages) are non-procedural languages; they enable users and
developers to write programs that only specify what the computer is supposed to do and
not how it is meant to do it.

❑ Third-generation languages are also known as high-level languages, while fourth-


generation languages are sometimes referred to as very-high-level programming
languages. When 3GL statements are generated, a large volume of assembly language and
machine language instructions are generated. Due to their reduced complexity, a fourth-
generation language only requires about ten percent of the statements that a third-
generation language requires to accomplish a similar task.

22
❑ The reduced complexity of fourth generation languages has also
increased the number of professionals who can take part in software
development. Most 4GLs are associated with data processing and
databases; they reflect the language used by domain professionals to
formulate business processing sequences and rules, thus facilitating the
efficient development of business-oriented systems. Most data-oriented
fourth-generation languages are SQL (Structured Query Language)
based. Java, C and C++ are common examples of third-generation
languages. High-level code is usually introduced to 4GLs in order to
introduce specific system logic.

23
Some high level programming language
1. Python
Python was first released in 1991 and created by Guido van Rossum. It’s the first love for any novice user since the
early 1980s. Python is one of the simplest languages considered to be a high-level, general-purpose interpreted
programming language.
This futuristic user-friendly programming language is fast to code and easy to learn.
According to a report from IEEE Spectrum, Python is a king for a majority of ranking metrics, and it reigns in the
enterprise, web, and embedded programming landscapes.
Advantage
Extensive library support
This versatile language is used to develop a
Object-oriented language
variety of applications. It offers a seamless
experience and is provided with endless
High-level language
possibilities to create the next big thing using User-friendly data structures
trending technologies like artificial Platform Independency
intelligence and machine learning. Presence of third-party modules
Open-source with the ever-growing popularity
Easy to learn
Offer the ability to develop a complex application
User-friendly data structures
Focuses on the code readability
24 Databases Connectivity
Application
Operating System Development
Web Framework and Web Application Development
Enterprise and business applications
For Prototyping
Graphical User Interface Desktop Application Development
For Game Development
Data Analysis
Image processing
Scientific Applications

25
2. Java
Being in the industry for years, it captures the developer’s attention. It first
appeared in 1995, with flexible options to run any browser window.
It was develop at sun microsystem by team lead by James Gosling

Java is a general-purpose computer network programming language that is


simultaneous, class-based, object-oriented, and specially designed to have as
Advantage
few dependencies as possible on execution. It is designed to allow application Java supports
creators to “write once, run anywhere” (WORA), which means that compiled Multithreading
Java code can run on all Java-supporting systems without recompiling. Automatic Memory
Management
Stability and massive
community
Application Remote Method
Embedded Systems Invocation(RMI)
Web Applications
Development of Web Servers and Application Servers
The security risk is low
Development of Enterprise Applications Good for enterprise
Build Desktop GUI Applications by using AWT and Swing computing
Development of Game Engine
Development of Cloud Application
High-Level Language
Development of Distributed Application
26
3.C++
Bjarne Stroustrup developed C++ as an addition of the C
language with important, generic programming features.
C++ is one of the influential object-oriented, general-purpose
programming languages. It plays a crucial role in developing an
advanced game app offering lucrative gameplay.

Application
Advantage Development of Operating System
C++ support rich function library
C++ support Multi-paradigm Development of Game
C++ is an Object-Oriented Programming Language
Low-level Manipulation
Development of Web Browser
Memory Management Compiler Development
Scalability
Large Community Support Development of Graphics
Support Cross-Platform Banking Application
The speed of execution is fast.
Development of Database Software

27
4. Javascript
Advantage​
Javascript is a dynamic language that first Easy to learn
Client-Side Scripting Language
appeared in December 1995. It’s a It extended the functionality of
web page
prototype-based, multi-paradigm, powerful No Compilation is needed
Easy to debug and testing
language. Javascript supports object- Cross-platform Application
oriented, imperative, and declarative style by Speed is fast
Rich Interface
Web Application
Development
being the language of the web. Versatility Web Server Application
Rich Library
Development
It improves the possibility of data validation, Game Development using
ensuring no vulnerabilities. Javascript used HTML5
Mobile App Development
for both server-side and client-side Smart Watch Application
programming. Regular updates of this
language keep you updated and help you
meet market expectations.

28
TOP PROGRAMMING LANGUAGES

29
Machine independent and portability of a program

❑ All the high level languages are machine independent languages


because they are not directly related to the internal architecture of a
computer.
❑ What ever the hardware(memory(RAM, ROM),CPU, Cache Memory, data
bus etc.) used there is no great impact to the language.
❑ A C program once written for a particular hardware can be compiled and executed on any other
hardware with little to no change. Even if a change is required it is only in terms of platform ( OS )
specific functions and system calls. This is what the term machine independent implies. While
writing a program in C, you do not have to worry about the underlying hardware specific details of
your machine. Your compiler takes care of that. When you compile a C program for a particular
hardware, corresponding assembly code is generated. It is further linked with static and dynamic
libraries to give an executable file. It should be noted that though C is machine independent, the
executable file generated in the final step is Machine as well as Platform ( OS ) dependent.
30
A Machine Independent language is one that can run on any machine. An
example of this would be Java. Because of the Java Virtual Machine or JVM it
can take the compiled code for any given Java App and run it on the machine
you are attempting to run it on. The reason it can do this even when the
operating system (OS) is widely different, say between Windows and Apple or
Linux is that the JVM was designed to always recognize Java compiled code
and then interface that into the OS that the JVM is running on. What it also
means is that Windows has to use it's own special version of the JVM that is
different from the Apple version of the JVM. IT is the JVM that makes Java
Machine Independent.

31
Portability is a characteristic attributed to a computer program if it can be used in an
operating systems other than the one in which it was created without requiring major
rework. Porting is the task of doing any work necessary to make the computer program
run in the new environment. In general, programs written in c language interface are
portable. Ideally, such a program needs only to be compiled for the operating system to
which it is being ported. However, programmers using standard interfaces also
sometimes use operating system extensions or special capabilities that may not be
present in the new operating system. Uses of such extensions have to be removed or
replaced with comparable functions in the new operating system. In addition to
language differences, porting may also require data conversion and adaptation to new
system procedures for running an application.

32

You might also like