0% found this document useful (0 votes)
42 views18 pages

Complier Design Unit 1

Uploaded by

Md Shahid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views18 pages

Complier Design Unit 1

Uploaded by

Md Shahid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Unit-1 Compiler design

A compiler is software that translates or converts a program written in a high-level language


(Source Language) into a low-level language (Machine Language or Assembly
Language). Compiler design is the process of developing a compiler.

The development of compilers is closely tied to the evolution of programming languages and
computer science itself. Here's an overview of how compilers came into existence:

History of Compilers
In the 1950s, Grace Hopper developed the first compiler, leading to languages like FORTRAN
(1957), LISP (1958), and COBOL (1959). The 1960s saw innovations like ALGOL, and the
1970s introduced C and Pascal. Modern compilers focus on optimization, supporting object-
oriented features and Just-in-Time compilation. Compilers have revolutionized programming,
enabling complex systems and improving software efficiency.

Language Processing Systems


We know a computer is a logical assembly of Software and Hardware. The hardware knows a
language, that is hard for us to grasp, consequently, we tend to write programs in a high-level
language, that is much less complicated for us to comprehend and maintain in our thoughts.
Now, these programs go through a series of transformations so that they can readily be used by
machines. This is where language procedure systems come in handy.
High-Level Language to Machine Code

High-Level Language: If a program contains pre-processor directives such as #include or


#define it is called HLL. They are closer to humans but far from machines. These (#) tags are
called preprocessor directives. They direct the pre-processor about what to do.

Pre-Processor: The pre-processor removes all the #include directives by including the files
called file inclusion and all the #define directives using macro expansion. It performs file
inclusion, augmentation, macro-processing, etc. For example: Let in the source program, it is
written #include "Stdio. h". Pre-Processor replaces this file with its contents in the produced
output.
Assembly Language: It's neither in binary form nor high level. It is an intermediate state that
is a combination of machine instructions and some other useful data needed for execution.

Assembler: For every platform (Hardware + OS) we will have an assembler. They are not
universal since for each platform we have one. The output of the assembler is called an object
file. Its translates assembly language to machine code.

Compiler: The compiler is an intelligent program as compared to an assembler. The compiler


verifies all types of limits, ranges, errors, etc. Compiler program takes more time to run and it
occupies a huge amount of memory space. The speed of the compiler is slower than other
system software. It takes time because it enters through the program and then does the
translation of the full program.

Interpreter: An interpreter converts high-level language into low-level machine language, just
like a compiler. But they are different in the way they read the input. The Compiler in one go
reads the inputs, does the processing, and executes the source code whereas the interpreter does
the same line by line. A compiler scans the entire program and translates it as a whole into
machine code whereas an interpreter translates the program one statement at a time. Interpreted
programs are usually slower concerning compiled ones.

Relocatable Machine Code: It can be loaded at any point and can be run. The address within
the program will be in such a way that it will cooperate with the program movement.

Loader/Linker: Loader/Linker converts the relocatable code into absolute code and tries to
run the program resulting in a running program or an error message (or sometimes both can
happen). Linker loads a variety of object files into a single file to make it executable. Then
loader loads it in memory and executes it.

 Linker: The basic work of a linker is to merge object codes (that have not even been
connected), produced by the compiler, assembler, standard library function, and
operating system resources.

 Loader: The codes generated by the compiler, assembler, and linker are generally re-
located by their nature, which means to say, the starting location of these codes is not
determined, which means they can be anywhere in the computer memory. Thus the
basic task of loaders to find/calculate the exact address of these memory locations.

Overall, compiler design is a complex process that involves multiple stages and requires a deep
understanding of both the programming language and the target platform. A well-designed
compiler can greatly improve the efficiency and performance of software programs, making
them more useful and valuable for users.
Phases of a Compiler
There are two major phases of compilation, which in turn have many parts. Each of them takes
input from the output of the previous level and works in a coordinated way.

Analysis Phase
An intermediate representation is created from the given source code :
 Lexical Analyzer
 Syntax Analyzer
 Semantic Analyzer
 Intermediate Code Generator

Synthesis Phase
An equivalent target program is created from the intermediate representation. It has two parts :
 Code Optimizer
 Code Generator.

Compiler Construction Tools


Compiler construction tools are specialized software that help developers create compilers
more efficiently. Here are the key tools:

1. Parser Generators: It creates syntax analyzers (parsers) based on grammatical


descriptions of programming languages.

2. Scanner Generators: It produces lexical analyzers using regular expressions to define


the tokens of a language.

3. Syntax-Directed Translation Engines: It generates intermediate code in three-address


format from input comprising a parse tree.

4. Automatic Code Generators: It converts intermediate language into machine language


using template matching techniques.

5. Data-Flow Analysis Engines: It supports code optimization by analyzing the flow of


values throughout different parts of the program.

6. Compiler Construction Toolkits: It provides integrated routines to facilitate the


construction of various compiler components.

Types of Compiler
 Self Compiler: When the compiler runs on the same machine and produces machine
code for the same machine on which it is running then it is called as self compiler or
resident compiler.

 Cross Compiler: The compiler may run on one machine and produce the machine
codes for other computers then in that case it is called a cross-compiler. It is capable of
creating code for a platform other than the one on which the compiler is running.
 Source-to-Source Compiler: A Source-to-Source Compiler or transcompiler or
transpiler is a compiler that translates source code written in one programming
language into the source code of another programming language.

 Single Pass Compiler: When all the phases of the compiler are present inside a single
module, it is simply called a single-pass compiler. It performs the work of converting
source code to machine code.

 Two Pass Compiler: Two-pass compiler is a compiler in which the program is


translated twice, once from the front end and the back from the back end known as Two
Pass Compiler.

 Multi-Pass Compiler: When several intermediate codes are created in a program and a
syntax tree is processed many times, it is called Multi-Pass Compiler. It breaks codes
into smaller programs.

 Just-in-Time (JIT) Compiler: It is a type of compiler that converts code into machine
language during program execution, rather than before it runs. It combines the benefits
of interpretation (real-time execution) and traditional compilation (faster execution).

 Ahead-of-Time (AOT) Compiler: It converts the entire source code into machine code
before the program runs. This means the code is fully compiled during development,
resulting in faster startup times and better performance at runtime.

 Incremental Compiler: It compiles only the parts of the code that have changed, rather
than recompiling the entire program. This makes the compilation process faster and
more efficient, especially during development.

Operations of Compiler
These are some operations that are done by the compiler:
 It breaks source programs into smaller parts.
 It enables the creation of symbol tables and intermediate representations.
 It helps in code compilation and error detection.
 It saves all codes and variables.
 It analyses the full program and translates it.
 Convert source code to machine code.

Advantages of Compiler Design

 Efficiency: Compiled programs are generally more efficient than interpreted programs
because the machine code produced by the compiler is optimized for the specific
hardware platform on which it will run.

 Portability: Once a program is compiled, the resulting machine code can be run on any
computer or device that has the appropriate hardware and operating system, making it
highly portable.
 Error Checking: Compilers perform comprehensive error checking during the
compilation process, which can help catch syntax, semantic, and logical errors in the
code before it is run.

 Optimizations: Compilers can make various optimizations to the generated machine


code, such as eliminating redundant instructions or rearranging code for better
performance.

Disadvantages of Compiler Design


 Longer Development Time: Developing a compiler is a complex and time-consuming
process that requires a deep understanding of both the programming language and the
target hardware platform.

 Debugging Difficulties: Debugging compiled code can be more difficult than


debugging interpreted code because the generated machine code may not be easy to
read or understand.

 Lack of Interactivity: Compiled programs are typically less interactive than


interpreted programs because they must be compiled before they can be run, which can
slow down the development and testing process.

 Platform-Specific Code: If the compiler is designed to generate machine code for a


specific hardware platform, the resulting code may not be portable to other platforms.

Compiler construction tools


The compiler writer can use some specialized tools that help in implementing various phases
of a compiler. These tools assist in the creation of an entire compiler or its parts. Some
commonly used compiler construction tools include:

1. Parser Generator - It produces syntax analyzers (parsers) from the input that is based on a
grammatical description of programming language or on a context-free grammar. It is
useful as the syntax analysis phase is highly complex and consumes more manual and
compilation time. Example: PIC, EQM

2 Scanner Generator - It generates lexical analyzers from the input that consists of regular
expression description based on tokens of a language. It generates a finite automation to
recognize the regular expression. Example: Lex

3 Syntax directed translation engines - It generates intermediate code with three address
format from the input that consists of a parse tree. These engines have routines to traverse
the parse tree and then produces the intermediate code. In this, each node of the parse tree
is associated with one or more translations.
4 Automatic code generators - It generates the machine language for a target machine. Each
operation of the intermediate language is translated using a collection of rules and then is
taken as an input by the code generator. A template matching process is used. An
intermediate language statement is replaced by its equivalent machine language statement
using templates.

5 Data-flow analysis engines - It is used in code optimization. Data flow analysis is a key part
of the code optimization that gathers the information, that is the values that flow from one
part of a program to another.

6 Compiler construction toolkits - It provides an integrated set of routines that aids in


building compiler components or in the construction of various phases of compiler.

Features of compiler construction tools:

 Lexical Analyzer Generator: This tool helps in generating the lexical analyzer or
scanner of the compiler. It takes as input a set of regular expressions that define the
syntax of the language being compiled and produces a program that reads the input
source code and tokenizes it based on these regular expressions.

 Parser Generator: This tool helps in generating the parser of the compiler. It takes as
input a context-free grammar that defines the syntax of the language being compiled
and produces a program that parses the input tokens and builds an abstract syntax tree.

 Code Generation Tools: These tools help in generating the target code for the
compiler. They take as input the abstract syntax tree produced by the parser and
produce code that can be executed on the target machine.

 Optimization Tools: These tools help in optimizing the generated code for efficiency
and performance. They can perform various optimizations such as dead code
elimination, loop optimization, and register allocation.

 Debugging Tools: These tools help in debugging the compiler itself or the programs
that are being compiled. They can provide debugging information such as symbol
tables, call stacks, and runtime errors.

 Profiling Tools: These tools help in profiling the compiler or the compiled code to
identify performance bottlenecks and optimize the code accordingly.

 Documentation Tools: These tools help in generating documentation for the compiler
and the programming language being compiled. They can generate documentation for
the syntax, semantics, and usage of the language.

 Language Support: Compiler construction tools are designed to support a wide range
of programming languages, including high-level languages such as C++, Java, and
Python, as well as low-level languages such as assembly language.
 Cross-Platform Support: Compiler construction tools may be designed to work on
multiple platforms, such as Windows, Mac, and Linux.

 User Interface: Some compiler construction tools come with a user interface that
makes it easier for developers to work with the compiler and its associated tools.

Text Editor
A text editor plays a fundamental role in compiler design as the primary interface for users to
create and modify source code, which is then processed by a compiler. While not directly part
of the compilation process itself, the text editor is the initial stage in the software development
lifecycle where the program's logic is expressed in a human-readable format.

Key functions of a text editor in relation to compiler design:


 Source Code Creation and Modification:
The text editor allows programmers to write, edit, and save source code files
(e.g., .c, .cpp, .java). This code serves as the input for the compiler.

 Plain Text Representation:


Text editors typically work with plain text, which is the standard format for source
code. This ensures that the code can be easily parsed and interpreted by the lexical
analysis phase of the compiler.

 Syntax Highlighting (in advanced editors):


Many modern text editors offer syntax highlighting, which visually distinguishes
keywords, operators, and other language constructs. While this is primarily for developer
convenience, it aids in writing syntactically correct code, reducing errors that the compiler
would otherwise catch.

 Basic Text Manipulation:


Features like searching, replacing, copying, pasting, and navigating within the text are
crucial for efficient code editing and organization before compilation.

 Integration with Build Systems (in IDEs/advanced editors):


Integrated Development Environments (IDEs), which often incorporate text editors,
provide direct integration with compilers and build systems, allowing users to compile and
run their code directly from the editor environment.
Type Example Features Use in Compiler Design
Line Editor ed, ex Line-by-line editing Historical, rare use today
Command-based, batch
Stream Editor Sed Code preprocessing
processing
Screen-Based Full-screen, keyboard Widely used in
vim, emacs
Editor navigation system/compiler dev
GUI-Based GUI, plugins, real-time Writing source & compiler
VS Code, Sublime
Editor editing code
Integrated Editor Eclipse, Code editing + Complete compiler
(IDE) Code::Blocks compiling/debugging development

Advantages of text editor

1.Source Code Creation

 Text editors are essential tools for writing source code in various programming
languages (e.g., C, Java), which the compiler will process.

2. Lightweight Development Environment

 Allows for quick writing and editing of source files without the overhead of full IDEs,
especially useful in educational and low-resource environments.

3. Syntax Formatting

 Many modern text editors highlight syntax errors and support language-specific
formatting, which helps catch basic mistakes before compilation.

4. Version Control Integration

 Text editors can integrate with Git, useful when tracking changes in a compiler’s source
code or testing changes in the language being compiled.

5. Multi-Language Support

 Useful when a compiler project is written in multiple languages (e.g., C++ for the
compiler core, Python for tooling).

DISADVANTAGES OF TEXT EDITORS


1. Lack of Compiler Integration

 Unlike IDEs, basic text editors don’t integrate tightly with compilers, so the
compilation and debugging process must be done manually.

2. No Real-Time Error Checking

 Unlike IDEs that show compiler errors in real-time, text editors often require you to
compile externally to see errors.

3. Limited Debugging Tools

 Text editors usually lack built-in debuggers, profilers, or memory inspection tools
needed for compiler development.

4. Manual Build Process

 Compiler development involves frequent builds. Without automation (e.g., makefiles,


build scripts), text editors don't manage this efficiently.

5. Harder for Large-Scale Projects

 Navigating large codebases (like compilers) is easier in IDEs with features like code
navigation, class hierarchies, and refactoring tools.

INTERPRETER
All high-level languages need to be converted to machine code so that the computer can
understand the program after taking the required inputs. The software by which the conversion
of the high-level instructions is performed line-by-line to machine-level language, other than
compiler and assembler, is known as interpreter.

The interpreter in the compiler checks the source code line-by-line and if an error is found on
any line, it stops the execution until the error is resolved. Error correction is quite easy for the
interpreter as the interpreter provides a line-by-line error. But the program takes more time to
complete the execution successfully. Interpreters were first used in 1952 to ease programming
within the limitations of computers at the time. It translates source code into some efficient
intermediate representation and executes them immediately.

Source programs are compiled before time and stored as machine-independent code, which is
then linked at run-time and executed by an interpreter. An Interpreter is generally used in
micro-computers. It helps the programmer to find out the errors and to correct them before the
control moves to the next statement. The interpreter system performs the actions described by
the high-level program. For interpreted programs, the source code is needed to run the program
every time. Interpreted programs run slower than the compiled programs.
Self-Interpreter is a programming language interpreter which is written in a language that can
interpret itself.
For Example: BASIC interpreter written in BASIC(Beginner's All-purpose Symbolic
Instruction Code). They are related to self-hosting compilers. Some languages have elegant
self-interpreters such as Lisp and Prolog.

Advantages and Disadvantages of Interpreters

 The advantage of the interpreter is that it is executed line by line which helps users to find
errors easily.
 The disadvantage of the interpreter is that it takes more time to execute successfully than
the compiler.

Applications of Interpreters

 Each operator executed in a command language is usually an invocation of a complex


routine, such as an editor or compiler so they are frequently used to command
languages and glue languages.
 Virtualization is often used when the intended architecture is unavailable.
 Sand-boxing
 Self-modifying code can be easily implemented in an interpreted language.
 Emulator for running Computer software written for obsolete and unavailable hardware
on more modern equipment

Debug monitor

A debug monitor is a tool or software component used in software development and debugging
processes. Its primary function is to monitor the execution of a program, allowing developers to
track its behavior, identify issues, and analyze performance. Here are some key aspects of debug
monitors:

1. Real-Time Monitoring: It provides real-time feedback on the program's execution,


including variable values, memory usage, and call stack information.

2. Breakpoints: Developers can set breakpoints to pause execution at specific lines of


code, enabling them to inspect the state of the application at that point.

3. Logging: Debug monitors often include logging capabilities to record events, errors,
and warnings during execution, which can be reviewed later.

4. Performance Analysis: Some debug monitors also offer profiling features to help
identify performance bottlenecks (बाधाओं) or resource usage issues.
5. Integration: They can be integrated into development environments (IDEs) or used as
standalone tools, depending on the programming language and platform.

A Debug Monitor is a software or hardware tool used to observe, control, and debug the
execution of a program — especially at the low level (machine or assembly language). It helps
developers track down bugs, inspect memory, and monitor CPU registers or I/O operations
during program execution.

It is particularly useful in:

 Embedded systems
 Low-level programming
 Operating system development
 Compiler and interpreter debugging

Advantages:

 Helps detect hard-to-find runtime bugs


 Offers precise control over execution
 Essential in embedded systems where traditional debugging tools may not work

❌ Disadvantages:

 Requires low-level knowledge (assembly, registers, etc.)


 Complex for beginners
 May slow down execution or require special hardware access

System programming environment

A programming environment refers to a complete set of tools such as an assembler, linker,


loader, debugger, and graphical interface that supports sprogrammers in developing software for
custom processors.

Compiler design, a system programming environment refers to the collection of tools,


languages, and utilities that enable developers to write, build, test, and debug a compiler.
Since a compiler itself is a complex system software, it requires a robust environment that
supports low-level programming and system interactions.

Component Role in Compiler Design


Text Editor Write compiler source code (lexical analyzer, parser, code
gen)
System Programming Usually C, C++, or Assembly for efficiency and low-level
Language control
Compiler/Assembler Compile the compiler code itself
Linker Link various compiled modules into one executable
Debugger Debug compiler programs to fix logical and runtime errors
Build Automation Tools Automate compilation steps (e.g., make, cmake)
Lexical Analyzer Generators Tools like Lex or Flex to generate tokenizers
Parser Generators Tools like Yacc, Bison, or ANTLR to generate parsers
Operating System Provides system calls, memory management, and process
control

Loader in Compiler Design (A)


In compiler design, a loader is a program that is responsible for loading executable programs into
memory for execution. The loader reads the object code of a program, which is usually in binary
form, and copies it into memory. It also performs other tasks such as allocating memory for the
program's data and resolving any external references to other programs or libraries. The loader is
typically part of the operating system and is invoked by the system's bootstrap program or by a
command from a user.
Loaders can be of two types:
 Absolute Loader: It loads a program at a specific memory location, specified in the
program's object code. This location is usually absolute and does not change when the
program is loaded into memory.
 Relocating Loader: It loads a program at any memory location, and then adjusts all memory
references in the program to reflect the new location. This allows the same program to be
loaded into different memory locations without having to modify the program's object code.

Architecture of Loader

Below is the Architecture of the Loader:

The architecture of a loader in a compiler design typically consists of several components:


1. Source program: This is a program written in a high-level programming language that
needs to be executed.
2. Translator: This component, such as a compiler or interpreter, converts the source program
into an object program.
3. Object program: This is the program in a machine-readable form, usually in binary, that
contains both the instructions and data of the program.
4. Executable object code: This is the object program that has been processed by the loader
and is ready to be executed.
Overall, the Loader is responsible for loading the program into memory, preparing it for
execution, and transferring control to the program's entry point. It acts as a bridge between the
Operating System and the program being loaded.

Features of Loaders

 Relocation: Loaders can relocate the program to different memory locations to avoid
memory conflicts with other programs.
 Linking: Loaders can link different parts of the program to resolve external references and
create a single executable program.
 Error Detection: Loaders can detect and report errors that occur during the loading process.
 Memory Allocation: Loaders can allocate memory space to the program and its data,
ensuring that the program has enough memory to execute efficiently.
 Execution Preparation: Loaders can prepare the program for execution by setting up the
initial values of the program counter and stack pointer.
 Dynamic Loading: Loaders can load program segments dynamically, allowing the program
to only load the necessary segments into memory as they are needed.

Advantages of Loader

There are several advantages of using a loader in compiler design:


1. Memory management: The loader is responsible for allocating memory for the program's
instructions and data. This allows the program to execute in a separate, protected area of
memory, which can help prevent errors in the program from affecting the rest of the system.
2. Dynamic linking: The loader can resolve external references to other programs or libraries
at runtime, which allows for more flexibility in the design of the program. This means that if
a library is updated, the program will automatically use the new version without requiring
any changes to the program's object code.
3. Relocation: The loader can relocate a program to any memory location, which allows for
efficient use of memory and prevents conflicts with other programs.
4. Error handling: The loader can check the compatibility of the program with the system and
handle any errors that occur during loading, such as missing libraries or incompatible
instruction sets.
5. Modularity: The loader makes it possible to develop and use separate modules or
components, which can be linked together to form a complete program. This allows for a
more modular design, which can make programs easier to maintain and update.
6. Reusability: As the program is separated into different modules, it can be reused in other
programs. The loader also allows the use of shared libraries, which can be used by multiple
programs.
7. Ease of use: The loader provides a simple and consistent interface for loading and executing
programs, which makes it easier for users to run and manage programs on their system.
Disadvantages of Loader

There are several disadvantages of using a loader in compiler design:


1. Complexity: Loaders can be complex to implement and maintain, as they need to perform a
variety of tasks such as memory management, symbol resolution, and relocation.
2. Overhead: Loaders introduce additional overhead in terms of memory usage and execution
time, as they need to read the object code from storage and perform various operations before
the program can be executed.
3. Size limitations: Loaders have limitations on the size of the program that can be loaded and
might not be able to handle large programs or programs with a lot of external references.
4. Limited Flexibility: Loaders are typically specific to a particular operating system or
architecture, and may not be easily portable to other systems.
5. Security: A poorly designed or implemented loader can introduce security vulnerabilities,
such as buffer overflows or other types of memory corruption.
6. Error handling: Loaders need to handle various types of errors, such as missing libraries,
incompatible object code, and insufficient memory.
7. Overlapping Memory: Due to the use of dynamic loading and relocation, the same memory
location may be used by multiple programs leading to overlapping memory.

Applications of Loader

1. Memory Management: The loader is responsible for allocating memory for the program's
instructions and data. It ensures that the program has enough memory to run and that the
memory is used efficiently.
2. Symbol Resolution: The loader resolves any external references to other programs or
libraries that the program may use. It finds and loads the required libraries and links them to
the program, so the program can access them during execution.
3. Error Handling: The loader checks the program for compatibility with the system and
handles any errors that may occur during the loading process. For example, if the program
requires a library that is not present on the system, the loader will display an error message.
4. Relocation: The loader relocates the program if necessary, adjusting all memory references
in the program to reflect the new location. This allows the same program to be loaded into
different memory locations without having to modify the program's object code.
5. Protection: The loader provides protection mechanisms to prevent unauthorized access to
the program. It prevents the program from overwriting or corrupting other programs or
system memory.
6. Dynamic Linking: The loader can dynamically link libraries and other shared object codes
to the program while it is being loaded, eliminating the need for them to be included in the
program's object code.
7. Overlays: The loader can load programs in chunks called overlays, which allows programs
to run in a smaller memory space by only loading the needed parts of the program at a time.
8. Microcode loading: Some processors use microcode as a low-level intermediate
representation of the instruction set, which is loaded by the loader into the microcode
memory before execution.
Loader Schemes in Compiler Design
A Loader is a system program that takes the object code generated by the compiler/assembler
and places it into main memory so it can be executed. It also performs tasks like address
relocation, linking, and program loading.
Compile-and-Go Loader
• The simplest loader scheme.

• Here, the assembler/ compiler directly places the translated program into memory and starts
execution.

• No separate object code file is created.

• Advantages: Simple, no need for separate loader.

• Disadvantages: Recompilation needed for every run, memory cannot be reused efficiently.

General Loader Schemes

• Tasks performed: Loading, Relocation, Linking, Binding.

Absolute Loader

• Assumes that assembler/compiler has already generated absolute addresses.

• Loader just reads the program into memory and starts execution.

• Advantages: Very simple and fast.

• Disadvantages: Programmer must know exact memory location, no flexibility.

Subroutine Linkage

• Mechanism to jump between subroutines.

• Compile-time linkage: addresses fixed during compilation.

• Load-time linkage: resolved during loading.

• Run-time linkage: resolved during execution.

Relocating Loader

• Can modify object code so it can be loaded into any memory location.
• Uses relocation bits to identify address-dependent instructions.

• Advantages: Flexible, better memory utilization.

Direct Linking Loader (DLL)

• Performs both relocation and linking.

• Reads multiple object modules, resolves external references, and links them together.

• Uses a linking directory to map symbols and addresses.

Loader, Binders, Linking Loader

• Binder: Combines different object modules and libraries into one unit before loading.

• Linking Loader: Performs both loading and linking at the same time, resolves symbolic
references, allocates memory, produces executable program.

Overlays

• Technique used when program is larger than available memory.

• Program is divided into modules (overlays).

• Only required module is kept in memory at a time.

• Advantages: Executes programs larger than memory, efficient memory usage.

• Disadvantages: Programmer must design overlay structure, complexity increases.

Summary Table

Loader Scheme Key Feature Advantage Disadvantage


Compile-and-Go Direct execution Simple Recompilation
from compiler every run
Absolute Loader Loads program at Fast No relocation
fixed address
Relocating Loader Can adjust Flexible Slower than
addresses absolute
Direct Linking Links multiple Supports More complex
Loader modules modularity
Linking Loader Loads + links in Convenient Slower load time
one step
Overlays Load part of Saves memory Complex to design
program on demand

You might also like