Machine Independent Features

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Loaders Dr. Monther Aldwairi 10/21/2007 Dr. Monther Aldwairi.
1 Loaders and Linkers Chapter 3 System Software An introduction to systems programming Leland L. Beck.
Chapter 3 Loaders and Linkers
Linkage Editors Difference between a linkage editor and a linking loader: Linking loader performs all linking and relocation operations, including automatic.
Linking & Loading CS-502 Operating Systems
3. Loaders & Linkers1 Chapter III: Loaders and Linkers Chapter goal: r To realize how a source program be loaded into memory m Loading m Relocation m Linking.
Chapter 3 Loaders and Linkers
COP 3402 Systems Programming Dr. Ali Orooji School of EECS University of Central Florida.
Chapter 3 Loaders and Linkers. Purpose and Function Places object program in memory Linking – Combines 2 or more obj programs Relocation – Allows loading.
Loaders and Linkers CS 230 이준원. 2 Overview assembler –generates an object code in a predefined format »COFF (common object file format) »ELF (executable.
SYSTEM PROGRAMMING & SYSTEM ADMINISTRATION
Mr. D. J. Patel, AITS, Rajkot 1 Operating Systems, by Dhananjay Dhamdhere1 Static and Dynamic Memory Allocation Memory allocation is an aspect of a more.
Machine Independent Assembler Features
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Loaders and Linkers Object Program contains the information:
Systems Software.
Machine-Independent Loader Features
Chap 3 Loaders and Linkers. Object program contains translated instructions and data values from the source program. Loading, which brings the object.
1 Machine-Independent Features Automatic Library Search automatically incorporate routines from a subprogram library Loading Options.
Chapter 6: Machine dependent Assembler Features
CS2422 Assembly Language and System Programming Linking Loader Department of Computer Science National Tsing Hua University.
CS2422 Assembly Language & System Programming January 2, 2007.
Loader- Machine Independent Loader Features
An introduction to systems programming
1 Chapter 3 Loaders and Linkers Source Program Assembler Object Code Loader Executable Code Linker.
Loader- Machine Dependent Loader Features
Separate Assembly allows a program to be built from modules rather than a single source file.
A Simple Two-Pass Assembler
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Loader and Linker.
Linking Loader untuk SIC/XE Machine. Lebih Lanjut mengenai Absolute Loader Shortcoming of an absolute loader –Programmer needs to specify the actual address.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 – Loaders.
Loaders and Linkers T 李俊葦. 1. Loader Accepts the object programs , prepares these programs for execution by the computer , and indicates the execution.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Binding & Dynamic Linking Presented by: Raunak Sulekh(1013) Pooja Kapoor(1008)
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 –Linkers.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 9 - Assembler 4.
Lecture 3 Translation.
Machine dependent Assembler Features
Computer Science 210 Computer Organization
System Programming and administration
Linking & Loading.
Memory Management © 2004, D. J. Foreman.
Chapter 8 Main Memory.
Separate Assembly allows a program to be built from modules rather than a single source file assembler linker source file.
Chapter 9 : Assembler Design Options
CS-3013 Operating Systems C-term 2008
Assembler Design Options
Computer Science 210 Computer Organization
Assemblers - 2 CSCI/CMPE 3334 David Egle.
Loaders and Linkers CSCI/CMPE 3334 David Egle.
Loaders and Linkers: Features
Chapter 2: System Structures
Loaders and Linkers.
Assembler Design Options
Memory Management Tasks
Linking & Loading CS-502 Operating Systems
A Simple Two-Pass Assembler
Optional Assembler Features 2
System Programming by Leland L. Beck Chapter 2
Machine Independent Assembler Features
Linking & Loading CS-502 Operating Systems
Machine Independent Assembler Features
An introduction to systems programming
UNIT III LOADERS AND LINKERS
Chapter 3 Loaders and Linkers
Presentation transcript:

Machine Independent Features

Automatic Library Search Many linking loaders can automatically incorporate routines from a subprogram library into the program being loaded. (E.g., the standard C library) The subroutines called by the program are automatically fetched from the library, linked with the main program, and loaded. The programmer does not need to take any action beyond mentioning the subroutine names as external references in the source program

Automatic Library Search Linking loader that support automatic library search must keep track of external symbols that are referred to, but not defined, in the primary input to the loader. At the end of pass 1, the symbols in ESTAB that remain undefined represent unresolved external references. The loader searches the library for routines that contain the definitions of these symbols, and processes the subroutines found by this search process exactly as if they had been part of the primary input stream.

Automatic Library Search The subroutines fetched from a library in this way may themselves contain external references. It is necessary to repeat the library search process until all references are resolved. If unresolved references remain after the library search is completed, they are treated as errors. If a symbol (or a subroutine name) is defined both in the source program and in the library, the one in the source program is used first.

Loader Options Many loaders allow the user to specify options that modify the standard processing. For example: Include program-name (library name) Direct the loader to read the designated object program from a library Delete csect-name Instruct the loader to delete the named control sections from the set of programs being loaded Change name1, name2 Cause the external symbol name1 to be changed to name2 wherever it appears in the program

Loader Options Application In the COPY program, we write two subroutines RDREC and WRREC to perform read records and write records. Suppose that the computer system provides READ and WRITE subroutines which has similar but advanced functions. Without modifying the source program and reassembling it, we can use the following loader options to make the COPY object program use READ rather than RDREC and WRITE rather than WRREC. Include READ (Util) Include WRITE (Util) Delete RDREC, WRREC Change RDREC, READ Change WRREC, WRITE

Loader Design Options

Linking Loader Linkage editor

Linkage Editor The difference between a linkage editor and a linking loader: A linking loader performs all linking and relocation operations, including automatic library search, and loads the linked program into memory for execution. A linkage editor produces a linked version of the program, which is normally written to a file for later execution.

Linkage Editor When the user is ready to run the linked program, a simple relocating loader can be used to load the program into memory. The only object code modification necessary is the addition of an actual address to relative values within the program. The linkage editor performs relocation of all control sections relative to the start of the linked program.

Linkage Editor All items that need to be modified at load time have values that are relative to the start of the linked program. This means that the loading can be accomplished in one pass with no external symbol table required. Thus, if a program is to be executed many times without being reassembled, the use of a linkage editor can substantially reduces the overhead required. Resolution of external references and library searching are only performed once.

Dynamic Linking Linkage editors perform linking before the program is loaded for execution. Linking loaders perform these same operations at load time. Dynamic linking postpones the linking function until execution time. A subroutine is loaded and linked to the test of the program when it is first called.

Dynamic Linking Application Dynamic linking is often used to allow several executing programs to share one copy of a subroutine or library. For example, a single copy of the standard C library can be loaded into memory. All C programs currently in execution can be linked to this one copy, instead of linking a separate copy into each object program.

Dynamic Linking Application In an object-oriented system, dynamic linking is often used for references to software object. This allows the implementation of the object and its method to be determined at the time the program is run. (e.g., C++) The implementation can be changed at any time, without affecting the program that makes use of the object.

Dynamic Linking Advantage The subroutines that diagnose errors may never need to be called at all. However, without using dynamic linking, these subroutines must be loaded and linked every time the program is run. Using dynamic linking can save both space for storing the object program on disk and in memory, and time for loading the bigger object program.

Dynamic Linking Implementation A subroutine that is to be dynamically loaded must be called via an operating system service request. This method can also be thought of as a request to a part of the loader that is kept in memory during execution of the program Instead of executing a JSUB instruction to an external symbol, the program makes a load-and-call service request to the OS. The parameter of this request is the symbolic name of the routine to be called..

Dynamic Linking Implementation The OS examines its internal tables to determines whether the subroutine is already loaded. If needed, the subroutine is loaded from the library. Then control is passed from the OS to the subroutine being called. When the called subroutine completes its processing, it returns to its caller (operating system). The OS then returns control to the program that issues the request. After the subroutine is completed, the memory that was allocated to it may be released.

Dynamic Linking Implementation However, often this is not done immediately. If the subroutine is retained in memory, it can be used by later calls to the same subroutine without loading the same subroutine multiple times. Control can simply pass from the dynamic loader to the called routine directly.

Implementation Example Issue a load-and-call service request Load the called subroutine into memory

Control is returned to the loader and later returned to the user program The called subroutine this time is already loaded. Control is passed to the loaded subroutine.