Presentation is loading. Please wait.

Presentation is loading. Please wait.

Loaders and Linkers: Features

Similar presentations


Presentation on theme: "Loaders and Linkers: Features"— Presentation transcript:

1 Loaders and Linkers: Features
CSCI/CMPE 3334 David Egle

2 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

3 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

4 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

5 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

6 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

7 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

8 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

9 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?

10 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

11 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

12 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

13 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

14 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

15 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

16 Implementation Examples
MS-DOS Linker SunOS Linker Cray MPP Linker

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


Download ppt "Loaders and Linkers: Features"

Similar presentations


Ads by Google