Loaders and Linkers: Features

Slides:



Advertisements
Similar presentations
1 Loaders and Linkers Chapter 3 System Software An introduction to systems programming Leland L. Beck.
Advertisements

Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3 J. Levine: Linkers & Loaders
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
CS 31003: Compilers ANIRUDDHA GUPTA 11CS10004 G2 CLASS DATE : 24/07/2013.
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:
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
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.
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
A Simple Two-Pass Assembler
MIPS coding. SPIM Some links can be found such as:
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.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
1 Assemblers System Programming by Leland L. Beck Chapter 2.
Loader and Linker.
UNIT III LOADERS AND LINKERS. This Unit gives you… Basic Loader Functions Machine-Dependent Loader Features Machine-Independent Loader Feature Loader.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
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.
Binding & Dynamic Linking Presented by: Raunak Sulekh(1013) Pooja Kapoor(1008)
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 –Linkers.
Lecture 3 Translation.
DDC 2223 SYSTEM SOFTWARE DDC2223 SYSTEM SOFTWARE.
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.
Program Execution in Linux
CS-3013 Operating Systems C-term 2008
Assembler Design Options
Assembler Design Options
Computer Science 210 Computer Organization
Assemblers - 2 CSCI/CMPE 3334 David Egle.
Loaders and Linkers CSCI/CMPE 3334 David Egle.
Machine Independent Features
Loaders and Linkers.
Memory Management Tasks
The Assembly Language Level
Linking & Loading CS-502 Operating Systems
A Simple Two-Pass Assembler
Optional Assembler Features 2
System Programming by Leland L. Beck Chapter 2
Assemblers CSCI/CMPE 3334 David Egle.
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:

Loaders and Linkers: Features CSCI/CMPE 3334 David Egle

Machine Independent Features Most loaders/linkers include fewer different features than are found in a typical assembler The following features are considered here: Automatic Library Search Loader Options

Automatic Library Search Handles case where programmer does not provide the object programs defining the external references A standard set of system libraries are automatically searched for those external references Other libraries to search may be specified by control statements or by parameters to the linking loader

Automatic Library Search - 2 The linking loader keeps track of external symbols that are referred to, but not defined these Refer record symbols are inserted in ESTAB and marked not defined a programmer can override a standard library by including it in the primary input to the loader At the end of pass 1, the undefined symbols represent unresolved external references the loader searches the libraries specified the routines fetched may contain external references repeat this process until all references are resolved

Automatic Library Search - 3 A library (object programs) search technique The linking loader could scan the Define records for all object programs this would be inefficient A special file structure is used for libraries – it contains a directory that specifies a routine name and a pointer to its address within the file a search in the directory is followed by reading the object programs the directory can be kept (by the OS) permanently in memory for faster search process

Loader Options Loader options modify its standard processing Many loaders have a special command language embedded in the primary input stream between object programs, in a separate input file, or included in the source program and retained in the object program

Loader Options – 2 Select alternate source of input read program-name from library-name as a primary input INCLUDE program-name (library-name) Delete external symbols or control sections DELETE csect-name Rename external symbol CHANGE name1, name2 Automatic inclusion of library routines searched before the standard system libraries LIBRARY MYLIB Don’t resolve some external reference routines that will not be performed in this execution NOCALL STDDEV, PLOT, CORREL

Loader Options – 3 Don’t resolve any external reference the program is linked but not executed a linkage editor performs this function Control the load map the loader outputs a load map might contain control section names, its addresses, external symbol addresses, or cross-reference table Other options specify the location at which the execution begin specify whether or not should execute the program if errors are detected

Loader Options Example The main program COPY uses the subprograms RDREC and WRREC (control sections used only with COPY) We want COPY to use the utility subroutines READ and WRITE that are available in UTLIB INCLUDE READ(UTLIB) INCLUDE WRITE(UTLIB) DELETE RDREC, WRREC CHANGE RDREC, READ CHANGE WRREC, WRITE How might the loader handle these commands?

Loader Design Options A linking loader performs linking and relocations when loading the program into memory for execution (described in previous sections) A linkage editor performs linking prior to load time In dynamic linking the linking is performed at execution time

Linkage Editor Produces a linked version of the program written to a file for later execution often called a load module, or an executable image Performs relocation of all control sections relative to the start of the linked program resolves external references and library searching Later, a one-pass relocating loader loads the program into memory for execution

Linkage Editor – 2 Reduces the overhead if the program to be executed many times Information concerning external references is often retained in the linked program to allow replacing control sections, modifying external references, etc. Can be used to build packages of control sections (libraries) If the actual program load address is known in advance an exact image of the program is produced Often has an option that allows the user to specify not to resolve external reference by automatic library search only resolves user-written routines requires a linking loader at execution time saving in library space vs. overhead

Dynamic Linking In dynamic linking, a subroutine is loaded and linked when it first called also called dynamic-loading or load-on-call The binding of the name to an actual address is delayed from load time until execution time

Dynamic Linking Advantages Allows several executing programs to share one copy of a subroutine or library Allows the implementation of a software “object” to be determined at the time the program is run Allows the ability to load subroutines only when (and if) they are needed substantial saving if a program contains large subroutines that are rarely called

Dynamic Linking Mechanism Instead of executing JSUB instruction the program makes a load-and-call service request to the OS the parameter to this request is the symbolic name of the subroutine The OS examines its internal tables to determine whether or not the subroutine is already loaded If necessary, the subroutine is loaded Control is passed from the OS to the subroutine When the called subroutine completes its processing, it returns to its caller (OS). The OS returns control to the program the OS might release the subroutine memory or retain it for later calls

Implementation Examples MS-DOS Linker SunOS Linker Cray MPP Linker

Problems 3.1 3.2 3.3 3.4 #1 is part of Phase 4 #7 (problems), 13 #3 #3, 4, 5, 6