1 / 14

COP 3402 Systems Programming

COP 3402 Systems Programming. Dr. Ali Orooji School of EECS University of Central Florida. 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.

rusti
Download Presentation

COP 3402 Systems Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  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. 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. Linking (Program Linking) Figure 3.8 on pages 136-137 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. PROGB … LISTB EQU * … ENDB EQU * … PROGC … LISTC EQU * … ENDC EQU * …

  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. 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. 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. 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. 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. object program object program linkage editor linking and relocating loader Linked program Memory relocating loader Memory Linkage Editors Figure 3.13 on page 153 of text

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

  13. dynamic loader user program 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

  14. 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

More Related