1 Machine-Independent Features Automatic Library Search automatically incorporate routines from a subprogram library Loading Options.

Slides:



Advertisements
Similar presentations
Loaders Dr. Monther Aldwairi 10/21/2007 Dr. Monther Aldwairi.
Advertisements

1 Loaders and Linkers Chapter 3 System Software An introduction to systems programming Leland L. Beck.
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3 J. Levine: Linkers & Loaders
Chapter 3 Loaders and Linkers
Loaders & Linkers. Introduction A “Loader” is a program which accepts the object program as input, makes them executable by the computer and initiates.
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.
Loader. Role of Loader Source Program Translator Object Program Loader Object program ready for execution Memory Translator – Assembler/Compiler.
Loaders and Linkers CS 230 이준원. 2 Overview assembler –generates an object code in a predefined format »COFF (common object file format) »ELF (executable.
Lecture 10: Linking and loading. Lecture 10 / Page 2AE4B33OSS 2011 Contents Linker vs. loader Linking the executable Libraries Loading executable ELF.
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.
Computer Organization CS224 Fall 2012 Lesson 12. Synchronization  Two processors or threads sharing an area of memory l P1 writes, then P2 reads l Data.
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.
Chapter 3 System 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.
Programming Types of Testing.
Chih-Hung Wang Chapter 2: Assembler (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
Loader- Machine Independent Loader Features
CS2422 Assembly Language & System Programming December 22, 2005.
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
Chapter 91 Memory Management Chapter 9   Review of process from source to executable (linking, loading, addressing)   General discussion of memory.
A Simple Two-Pass Assembler
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
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.
Assemblers.
Chapter 1 Computer architecture Languages: machine, assembly, high
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
PART I SISTEM UTILITIES LECTURE 4.1 LINK_LOAD Ştefan Stăncescu 1.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
1 Assemblers System Programming by Leland L. Beck Chapter 2.
2 : Assembler 1 Chapter II: Assembler Chapter goal: r Introduce the fundamental functions that any assembler must perform. m Assign machine address m Translate.
Loader and Linker.
CSc 453 Linking and Loading
Linking Loader untuk SIC/XE Machine. Lebih Lanjut mengenai Absolute Loader Shortcoming of an absolute loader –Programmer needs to specify the actual address.
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.
Hello world !!! ASCII representation of hello.c.
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.
Lecture 3 Translation.
System Programming and administration
Linking & Loading.
Separate Assembly allows a program to be built from modules rather than a single source file assembler linker source file.
Loaders and Linkers: Features
Machine Independent Features
Loaders and Linkers.
Memory Management Tasks
Linking & Loading CS-502 Operating Systems
A Simple Two-Pass Assembler
System Programming by Leland L. Beck Chapter 2
Loaders and Linkers.
Chapter 1 Computer architecture Languages: machine, assembly, high
An introduction to systems programming
UNIT III LOADERS AND LINKERS
Chapter 3 Loaders and Linkers
Presentation transcript:

1 Machine-Independent Features Automatic Library Search automatically incorporate routines from a subprogram library Loading Options

2 Automatic Library Search l Automatic library call »The programmer does not need to take any action beyond mentioning the subroutine names as external references l Solution 1Enter the symbols from each Refer record into ESTAB 2When the definition is encountered (Define record), the address is assigned 3At the end of Pass 1, the symbols in ESTAB that remain undefined represent unresolved external references 4The loader searches the libraries specified (or standard) for undefined symbols or subroutines

3 Automatic Library Search (Cont.) l The library search process may be repeated »Since the subroutines fetched from a library may themselves contain external references l Programmer defined subroutines have higher priority »The programmer can override the standard subroutines in the library by supplying their own routines l Library structures »Assembled or compiled versions of the subroutines in a library can be structured using a directory that gives the name of each routine and a pointer to its address within the library

4 Loader Options l Many loaders have a special command language that is used to specify options »a separate input file »source program »embedded in the primary input stream between programs l Command Language »specifying alternative sources of input –INCLUDEprogram-name(library-name) »changing or deleting external reference –DELETEname –CHANGEsymbol1, symbol2 »controlling the automatic library search –LIBRARYMYLIB

5 Loader Options (cont.) »specify that some references not be resolved –NOCALLname »specify the location at which execution is to begin l Example »If we would like to evaluate the use of READ and WRITE instead of RDREC and WRREC, for a temporary measure, we use the following loader commands –INCLUDEREAD(UTLIB) –INCLUDEWRITE(UTILB) –DELETERDREC, WRREC –CHANGERDREC, READ –CHANGEWRREC, WRITE »If it is know that the statistical analysis is not to be performed in an execution –NOCALLSTDDEV, PLOT, CORREL

6 Loader Design Options l Linkage Editors l Dynamic Linking l Bootstrap Loaders

7 Linkage Editors l Definition »A linkage editor produces a linked version of the program (often called a load module or an executable image) which is written to a file or a library for later execution l Procedure »A linkage editor performs relocation of all control sections relative to the start of the linked program, resolves all external reference, and output a relocatable module for later execution l A simple relocating loader can be used to load the program into memory (one-pass without external symbol table)

8 Linking Loader vs. Linkage Editor Processing of an object program using (a) linking loader and (b) linkage editor

9 Linking loader vs. linkage editors l Comparison »Linking Loader: performs all linking and relocation operations, including library search if specified, and loads the linked program directly into memory for execution »Linkage Editors: produces a linked version of the program (often called a load module or an executable image), which is written onto a file or library for later execution »Resolution of external reference and library searching are only performed once for linkage editor –If a program is to be executed many times without being reassembled, the use of a linkage editor substantially reduces the overhead required. –If a program is under development or is used infrequently, the use of a linking loader outperforms a linkage editor

10 Linkage Editors (Cont.) l Other functions »produce core image if actual address is known in advance »improve a subroutine (PROJECT) of a program (PLANNER) without going back to the original versions of all of the other subroutines INCLUDE PLANNER(PROGLIB) DELETE PROJECT{delete from existing PLANNER} INCLUDE PROJECT(NEWLIB){include new version} REPLACE PLANNER(PROGLIB) –external references are retained in the linked program

11 Linkage Editors (Cont.) »build packages of subroutines or other control sections THAT ARE GENERALLY USED TOGETHER –example INCLUDEREADR(FTNLIB) INCLUDEWRITER(FTNLIB) INCLUDEBLOCK(FTNLIB) INCLUDE DEBLOCK(FTNLIB) INCLUDEENCODE(FTNLIB) INCLUDE DECODE(FTNLIB). SAVE FTNIO(SUBLIB) »specify that external references are not to be resolved by automatic library search

12 Dynamic Linking l Comparison »Linkage editors perform linking operations before the program is loaded for execution »Linking loaders perform linking operations at load time »Dynamic linking (dynamic loading, load on call) perform linking at execution time l Delayed Binding »Avoid the necessity of loading the entire library for each execution, i.e. load the routines only when they are needed »Allow several executing programs to share one copy of a subroutine or library (Dynamic Link Library, DLL)

13 Dynamic Linking l Via an OS »dynamic loader is one part of the OS »Instead of executing a JSUB instruction that refers to an external symbol, the program makes a load-and-call service request to the OS »pass of control –User program -> OS –OS: load the subroutine –OS -> Subroutine –Subroutine -> OS –OS -> User program

14 Pass of control

15 Pass of Control

16 Bootstrap Loaders l Absolute loader »One some computers, an absolute loader program is permanently resident in a read-only memory ROM »One some computers, there’s a built-in hardware which read a fixed-length record from some device into memory at a fixed location. After the read operation, control is automatically transferred to the address in memory

17 Implementation Example -- MS-DOS l MS-DOS assembler (MASM) produce object modules (.OBJ) l MS-DOS LINK is a linkage editor that combines one or more modules to produce a complete executable program (.EXE) l MS-DOS object module »THEADERsimilar to Header record in SIC/XE »MODENDsimilar to End record in SIC/XE

18 MS-DOS object module »TYPDEFdata type »PUBDEFsimilar to Define record in SIC/XE »EXTDEFsimilar to Reference record in SIC/XE »LNAMEScontain a list of segments and class names »SEGDEFsegment define »GRPDEFspecify how segments are grouped »LEDATAsimilar to Text Record in SIC/XE »LIDATAspecify repeated instructions »FIXUPPsimilar to Modification record in SIC/XE

19 Repeated Instruction Suppose that the SIC assembler language is changed to include a new form of the RESB statement, such as RESBn‘c’ which reserves n bytes of memory and initializes all of these bytes to the character ‘c’. For example BUFFERRESB4096‘ ’ This feature could be implemented by simply generating the required number of bytes in Text records. However, this could lead to a large increase in the size of the object program.

20 LINK l Pass 1 »compute a starting address for each segment in the program –segment from different object modules that have the same segment name and class are combined –segments with the same class, but different names are concatenated –a segment’s starting address is updated as these combinations and concatenations are performed l Pass 2 »extract the translated instructions from the object modules »build an image of the executable program in memory »write it to the executable (.EXE) file

21 SunOS Linkers l Link-editor »relocatable object module, for further link-editing »static executable, ready to run »dynamic executable, some symbolic references need to be bound at run time »shared object, services that can be bound at run time to dynamic executables l Run-time linker

22 Run-Time Linker l Locate and include necessary shared objects l Lazy binding »binding of procedure calls is normally deferred until the program is in execution l Reduce the amount of overhead required for starting a program