Presentation is loading. Please wait.

Presentation is loading. Please wait.

COP 3402 Systems Programming Dr. Ali Orooji School of EECS University of Central Florida.

Similar presentations


Presentation on theme: "COP 3402 Systems Programming Dr. Ali Orooji School of EECS University of Central Florida."— Presentation transcript:

1 COP 3402 Systems Programming Dr. Ali Orooji School of EECS University of Central Florida

2 S3 - 2 Chapter 3 - LOADERS AND LINKERS object program contains translated instructions and data values from the source program, and specifies addresses in memory where these items are to be loaded Three Functions Loading brings the object program into memory for execution Relocation modifies the object program when the program is loaded at an address different from the location originally specified Linking combines two or more separate object programs

3 S3 - 3 Absolute Loader - no relocation - no linking Relocation (Program Relocation) two methods - modification records - bit mask (relocation bit) (if direct addressing and fixed instruction format)

4 S3 - 4 Linking (Program Linking) Figure 3.8 on pages of text PROGA... REF1 LDA LISTA REF2 +LDT LISTB+4 REF3 LDX #ENDA-LISTA... LISTA EQU *... ENDA EQU * REF4 WORD ENDA-LISTA+LISTC REF5 WORD ENDC-LISTC-10 REF6 WORD ENDC-LISTC+LISTA-1 REF7 WORD ENDA-LISTA-(ENDB-LISTB) REF8 WORD LISTB-LISTA

5 S3 - 5 PROGB … LISTB EQU * … ENDB EQU * … PROGC … LISTC EQU * … ENDC EQU * …

6 S3 - 6 Linking and Relocating Loader Let's assume control section 1 has external references to control section 2. Control section 2 comes after control section 1; so when loading control section 1 we don't know the addresses for variables in control section 2 - two passes Pass 1 assigns addresses to all external symbols Pass 2 performs loading, relocation, and linking

7 S3 - 7 Loader Data Structures external symbol table (ESTAB - ESTBL) name and address of each external symbol; and in which control section the symbol is defined program load address (PROGADDR) beginning address in memory where the linked program is to be loaded control section address (CSADDR) starting address assigned to the control section currently being scanned by the loader; starting address of the control section currently being loaded

8 S3 - 8 Loader Logic Pass 1 - Page 143 of text Pass 2 - Page 144 of text Figure 3.11(a) Algorithm for Pass 1 of a linking loader Figure 3.11(b) Algorithm for Pass 2 of a linking loader

9 S3 - 9 Section 3.3: Machine-Independent Loader Features Automatic Library Search standard system library other libraries - put external references in ESTBL - after processing the primary input to loader if unresolved external references search the libraries for the routines

10 S Section 3.4: Loader Design Options Linking (and Relocating) Loaders perform all linking and relocation at load time Linkage Editors perform linking prior to load time Dynamic Linking linking is performed at execution time Bootstrap Loaders - used to load the operating system or the loader itself into memory - used to run stand-alone programs independent of the operating system or the system loader

11 S Linkage Editors Figure 3.13 on page 153 of text object program linking and relocating loader Memoryobject program linkage editor Linked program relocating loader Memory

12 S Advantage avoids repeated linking Disadvantage requires extra writing to disk

13 S Dynamic Linking postpones the linking function until execution time: a subroutine is loaded and linked to the rest of the program when it is first called Advantage avoids unnecessary linking Figure 3.14 on page 157 of text dynamic loader user program

14 S Bootstrap Loaders How do we get the first program into memory? - operator enters into memory the object code for an absolute loader, using switches on the computer console - have absolute loader program in a read-only memory (ROM); when the operator presses "system start" button, the machine begins to execute this program - when pressing a button, a record is read from some device into memory at a fixed location; this record contains instructions for an absolute loader


Download ppt "COP 3402 Systems Programming Dr. Ali Orooji School of EECS University of Central Florida."

Similar presentations


Ads by Google