1 / 47

Chapter III: Loaders and Linkers

Chapter goal: To realize how a source program be loaded into memory Loading Relocation Linking. Overview: Design of an absolute loader The Bootstrap loader Relocation Program linking Algorithm for a linking loader Other loader design options. Chapter III: Loaders and Linkers. Loading

kelly-weeks
Télécharger la présentation

Chapter III: Loaders and Linkers

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. Chapter goal: To realize how a source program be loaded into memory Loading Relocation Linking Overview: Design of an absolute loader The Bootstrap loader Relocation Program linking Algorithm for a linking loader Other loader design options Chapter III: Loaders and Linkers 3. Loaders & Linkers

  2. Loading Bring the object program into memory for execution. Relocation Modifies the object program so that it can be loaded at an address different from the location originally specified. Linking Combines two or more separate object programs and supplies the information needed to allow references between them. Introduction 3. Loaders & Linkers

  3. Loader is a system program that performs the loading function. Linker perform the linking operations. P.s. 1. Many loader also support relocation and linking. P.s. 2. Some system have a linker to perform the linking operations and a separate loader to handle relocation and loading. Introduction (cont.) 3. Loaders & Linkers

  4. No need to perform functions as linking and program relocation. The operation is very simple. All functions are accomplished in a single pass. Basic loader functions – The absolute loader 3. Loaders & Linkers

  5. The Object code for the program in @2.1 3. Loaders & Linkers

  6. The Object code for the program in @2.1 (cont.) 3. Loaders & Linkers

  7. The Object code for the program in @2.1 (cont.) 3. Loaders & Linkers

  8. The object program for the program in @2.1 3. Loaders & Linkers

  9. Loading of an absolute program 3. Loaders & Linkers

  10. Algorithm for an absolute loader 3. Loaders & Linkers

  11. Basic loader functions – Bootstrap loader • When a computer is first turned on or restarted, a special type of absolute loader, called a bootstrap loader, is executed. • The bootstrap loader itself begins at address 0 in the memory of the machine. • It loads the operating system (or some other program) starting at address 80. 3. Loaders & Linkers

  12. Bootstrap loader for SIC/XE 3. Loaders & Linkers

  13. Bootstrap loader for SIC/XE (cont.) 3. Loaders & Linkers

  14. Machine-dependent loader features • The advantages and disadvantages for absolute loader • Advantage: Simple and efficient. • Disadvantage: Need the programmer to specify the actual address at which it will be loaded into memory. It is difficult to use subroutine libraries efficiently. • So we need --- the capability of program relocation. 3. Loaders & Linkers

  15. Machine-dependent loader features --- Relocation • Loaders that allow for program relocation are called relocating loadersorrelative loaders. • The relocating loaders need to take care of the modification record which must be changed when the program is relocated. 3. Loaders & Linkers

  16. Example of a SIC/XE program 3. Loaders & Linkers

  17. Example of a SIC/XE program (cont.) 3. Loaders & Linkers

  18. Example of a SIC/XE program (cont.) 3. Loaders & Linkers

  19. Object program with relocation by modification records. 3. Loaders & Linkers

  20. Relocation (cont.) • In SIC/XE machine, most of the code is not need to relocation (e.g., PC relative addressing or immediate addressing). Only the Format 4 (e.g, +SUB…) needed. • Since the SIC machine does not support the PC relative mode, so lots of the instructions need to be relocated. • The SIC machine use bit mask to indicate, whether the relocation is needed or not. • E.g., bit mask FFC (=1111 1111 1100) means the first 10 words need to be relocated. 3. Loaders & Linkers

  21. Relocatable program for a standard SIC machine 3. Loaders & Linkers

  22. Relocatable program for a standard SIC machine (cont.) 3. Loaders & Linkers

  23. Relocatable program for a standard SIC machine (cont.) 3. Loaders & Linkers

  24. Object program with relocation by bit mask. 3. Loaders & Linkers

  25. Program Linking 3. Loaders & Linkers

  26. Program Linking (cont.) 3. Loaders & Linkers

  27. Program Linking (cont.) 3. Loaders & Linkers

  28. Object program corresponding to above program 3. Loaders & Linkers

  29. Object program corresponding to above program(cont.) 3. Loaders & Linkers

  30. Object program corresponding to above program(cont.) 3. Loaders & Linkers

  31. External symbol table (ESTAB) 3. Loaders & Linkers

  32. Relocation an linking operations performed on REF4 from PROGA 3. Loaders & Linkers

  33. Program from above program after linking and loading 3. Loaders & Linkers

  34. Algorithm and Data structure for a Linking Loader • Two passes of a linking loader • Pass1 Assigns addresses to all external symbols • Pass2 Performs the actual loading, relocation, and linking. 3. Loaders & Linkers

  35. Algorithm and Data structure for a Linking Loader (cont.) 3. Loaders & Linkers

  36. Algorithm and Data structure for a Linking Loader (cont.) 3. Loaders & Linkers

  37. Enhancing the object program • Reference number • To indicated each external symbol referred to in a control section. • Reference number 01 is corresponding to the control section name. 3. Loaders & Linkers

  38. Enhancing the object program (cont.) 3. Loaders & Linkers

  39. Enhancing the object program (cont.) 3. Loaders & Linkers

  40. Enhancing the object program (cont.) 3. Loaders & Linkers

  41. Machine-independent loader features – Automatic library search • Automatic library call (library search) • Libraries such as mathematical or statistical routines. • The subroutines called by the program being loaded are automatically fetched from the library, linked with the main program, and loaded. • The programmer does not need to take any action beyond mentioning the subroutines names as external references in the source program. 3. Loaders & Linkers

  42. Machine-independent loader features – Loader options • A special command language that is used to specify options. • E.g., • INCLUDE program-name(library-name) • DELETE csect-name • CHANGE name1,name2 • INCLUDE READ(UTLIB) • INCLUDE WRITE(UTLIB) • DELETE RDREC, WRREC • CHANGE RDREC, READ • CHANGE WRREC, WRITE 3. Loaders & Linkers

  43. Loader design options – Linkage Editors • A linking loader performs all linking and relocation operations, and loads the linked program directly into memory for execution. • A linkage editor produces a linked version of the program (loader module or executable image) which is written to a file or library for later execution. 3. Loaders & Linkers

  44. Loader design options – Linkage Editors (cont.) 3. Loaders & Linkers

  45. Loader design options – Dynamic linking • The linkage editors perform linking operations before the program is loaded for execution. • The dynamic linking(dynamic loading or load on call) load a subroutine and linked to the rest of the program when it is first called. 3. Loaders & Linkers

  46. Loader design options – Dynamic linking (cont.) 3. Loaders & Linkers

  47. Loader design options – Dynamic linking (cont.) 3. Loaders & Linkers

More Related