jagomart
digital resources
picture1_Ceng332 Chp3


 156x       Filetype PDF       File size 0.04 MB       Source: www.cs.bilkent.edu.tr


File: Ceng332 Chp3
loaders a loader is a system program that performs the loading function systems programming many also support relocation linking others have a separate linker and loader a single loader and ...

icon picture PDF Filetype PDF | Posted on 04 Feb 2023 | 2 years ago
Partial capture of text on file.
                                                                                                                            Loaders
                                                                                                        • A loader is a system program that 
                                                                                                          performs the loading function.
                                   Systems  Programming                                                    – many also support relocation & linking 
                                                                                                           – others have a separate linker and loader
                                                                                                        • A single loader and linker exist on a 
                                                  Chapter 3                                               system since compilers/assemblers 
                                           Linkers and Loaders                                            produce object code in the same 
                                                                                                          format.
                                                                                     1                                                                         4
                                                  Outline                                                     Basic Loader Functions
                             • Design and implementation of linkers and                                 • bringing an object program into 
                                loaders                                                                   memory 
                                 – fundamental function:
                                    • loading an object program into memory for execution               • starting its execution
                                    • e.g.,an absolute loader for SIC machine 
                                 – relocation and linking
                                    • object program representation and machine 
                                      dependence
                                 – linking loader
                                 – machine independent loader features
                                 – linkage editors – perform linking before loading
                                 – dynamic linking – delaying linking until execution 
                                   time
                                                                                     2                                                                         5
                                             Introduction                                                      Design of an Absolute 
                                                                                                                             Loader
                             Object program:                                                            • Refer to Section 2.1&2.1.1 and Figure 3.1
                                 – contains translated instructions and data from                       • Its operation is very simple
                                   the source program,                                                     – no linking or relocation
                                 – specifies addresses in memory where these 
                                   items are to be loaded.                                              • Single pass operation
                             Loading: brings the object program into memory                                – check H record to verify that correct program 
                                for execution                                                                has been presented for loading
                             Relocation: modifies the object program so that it                            – read each T record, and move object code into 
                                can be loaded at an address different from the                               the indicated address in memory
                                location originally specified                                              – at  E record, jump to the specified address to 
                             Linking: combines two or more separate object                                   begin execution of the loaded program.
                                programs and supplies the information needed to 
                                allow references between them.
                                                                                     3                                                                         6
                                                                                                                                                                             1
                             • Figure 3.2                                                              • A more complex loader
                                                                                                          – suitable for SIC/XE and is typical of those 
                             • Each byte of assembled code is given using                                   found on most modern computers
                                Hex representation in character form                                      – supports relocation and linking 
                             • As the instruction is loaded for execution,                             • Section 3.2.1 – hardware dependencies
                                the operation code must be stored in a                                 • Section 3.2.2 – program linking from the 
                                single byte w/Hex value.                                                  loader’s point of view
                                                                                                          – not as machine dependent as relocation
                             • May prefer to store object code in binary                               • Section 3.3 – data structures and 
                                form  for obtaining more efficiency!                                      processing logic
                                                                                    7                                                                         10
                               A Simple Bootstrap Loader                                                                 Relocation
                             • Automatically executed when the computer                             Relocating loaders or relative loaders:
                                is first turned on                                                     loaders that allow for program relocation.
                             • Loads the first program to be run: usually                           Two methods for specifying relocation as part of 
                                the O/S.                                                                the object program:
                             • See Figure 3.3 – A bootstrap loader for                                  1. A Modification record (Section 2.3.5) is used to 
                                SIC/XE                                                                     describe each part of the object code that must be 
                                – itself begins at address 0 in memory                                     changed when the program is relocated
                                – loads the O/S starting at address 80                                     •  Figure 3.4 (same as 2.6) – XE program -> Figure 3.5
                                – Each byte of object code to be loaded is represented on 
                                  device F1 as two Hex digits                                              •  Most instructions in this XE program use relative 
                                – No H or E records, no control information (eoln)                            addressing, except lines 15, 35, and 65.
                                – After all code is loaded, bootstrap jumps to address 80.                 •  M00000705+COPY
                                – Subroutine GETC reads one char from device F1 and 
                                  converts it from ASCII char code to the value of the 
                                  hex digit that it represents                      8                                                                         11
                                 MACHINE-DEPENDENT LOADER                                                           Second method
                                                 FEATURES
                             • Disadvantages of absolute loader                                        2. Modification record scheme is not well suited 
                                – actual load address must be specified                                    for use with a machine like SIC
                                    • OK for SIC                                                           - SIC does not use relative addresses
                                    • problematic for an advanced machine where                              almost all instructions (except RSUB) must  
                                     several independent programs run together                               be modified  when the program is relocated.
                                     and share memory                                                      No Modification records
                                       – relocation is needed for efficient execution                      A relocation bit associated with each word of 
                                – difficult to use subroutine libraries                                    object code and they form a bit mask
                                  (scientific and mathematical) efficiently                         T00106119FE0040030E01079301064508039DC10792C00363810644C000005
                                    • important to be able to select and load                                     +     +     +     +     +     +     +
                                     exactly those routines that are needed                                 111111100000
                                                                                    9                                                                         12
                                                                                                                                                                            2
                                            Third method
                                3. Hardware relocation capability is                                  • REF3 – immediate operand whose value is 
                                    provided by some computers                                           to be the difference between ENDA and 
                                    - eliminates some of the need for the                                LISTA
                                    loader to perform relocation                                          – PROGA – knows all info
                                    - They keep all memory references to                                  – PROGB/C – values of labels are unknown
                                    be relative to the user’s assigned area                                  • must be assembled as an external reference 
                                    of memory                                                                  w/two modification records
                                    - Conversion takes place during 
                                    execution.
                                                                                   13                                                                        16
                                          Program Linking                                                         General approach
                             • Section 2.3.5, Figure 2.15                                             • to evaluate as much of the expression 
                                – a program w/3 control sections                                         as it can and to pass the remaining 
                                – They may be separately or together                                     terms to the loader via Modification 
                                  assembled                                                              records
                                    • result is separate segments of object code 
                                     after assembly
                                    • Figure 3.8                                                      • See REF4
                                    • set of references to external symbols:                              – PROGA – evaluate all except LISTC
                                       – instruction operands (REF1 – REF3)
                                       – values of data words (REF4 – REF8)                               – PROGB/PROGC – no terms can be 
                                          » We will examine the differences in the way                      evaluated
                                            these identical expressions are handled within 
                                            the three programs.
                                                                                   14                                                                        17
                             • REF1 –                                                                 • Fig 3.10 – three programs after loading and 
                                – PROGA – simply a reference to a label                                  linking
                                  within the program: PC-relative instr.                                  – REF4 – 8 has resulted in the same value
                                                                                                          – Figure 3.10.b – actual computation of REF4 in 
                                – PROGB/PROGC – refers to an external                                       PROGA
                                  symbol: extended-format instr.                                      • For the references that are instruction 
                                    • has a Modificiation record instructing the                         operands, the calculated values after 
                                     loader to add the value of LISTA to this                            loading do not always appear to be equal
                                     address during linking                                               – because, there is an additional address 
                             • REF2 –                                                                       calculation step involved for PC-relative 
                                                                                                            instructions (BUT target addresses are the 
                                – same as REF1 , except value of constant                                   same)
                                                                                                             • REF1 (PROGA: 01D PC-relative, PROGB: 4040 
                                                                                                               extended format)
                                                                                   15                                                                        18
                                                                                                                                                                           3
                             Algorithm and Data Structures 
                            for a Linking (Relocating) Loader
                             • More complicated than the absolute loader                                • Pass 2:
                             • We use Modification records for relocation                                  – does actual loading, relocation, and linking
                                 – so that linking and relocating functions are                            – As each Text record is read, the object code is 
                                   performed using the same mechanism                                        moved to the specified address
                             • Input: a set of object programs (control                                       • (plus the current value of CSADDR)
                                sections) that are to be linked together                                   – When a Modification record is encountered, the 
                                 – A CS may make an external ref. to a symbol                                mentioned symbol’s value is added or 
                                   whose def does not appear until later in this                             subtracted from the indicated location in 
                                   input stream until later CS is read.                                      memory
                                 – Two passes over input:                                               • Last step: transfer control to loaded program to 
                                    • Pass 1: assigns addresses to all external symbols                   begin execution.
                                    • Pass 2: performs the actual loading, relocation, and                 – indicated in the End record
                                      linking.                                                            Remark: Algorithm can be made more efficient 
                                                                                                          by changing the object code but this concerns the 
                                                                                    19                    implementors only!                                  22
                                    Main Data Structures                                                      MACHINE-INDEPENDENT 
                                                                                                                   LOADER FEATURES
                             • External Symbol Table (ESTAB)                                            • Loading and linking are often thought 
                                 – ~Symbol Table                                                          as O/S service functions.
                                 – stores the name and address of each external symbol in 
                                   the set of control sections being loaded.                               – The programmer’s connection with such 
                                 – also often indicates in which CS the symbol is defined.                   services is not as direct as it is with 
                                 – A hashed organization is typically used.                                  assemblers.
                             • Program Load Address (PROGADDR) 
                                 – beginning address inmemory where the linked program is                  – Most loaders include fewer different 
                                   to be loaded.                                                             features than are found in a typical 
                                 – supplied by the O/S
                             • Control Section Address (CSADDR)                                              assembler.
                                 – starting address asigned to the CS currently being                   • Automatic library search process for 
                                   scanned by the loader
                                 – Its value is added to all relative addresses within the                handling external references
                                   control section to convert them to actual addresses
                                                                                    20                                                                        23
                                           The Algorithm                                                   Automatic Library Search
                             • Refer to Fig.3.11                                                        • allow a programmer to use standard 
                             • Pass 1:                                                                    subroutines w/o explicitly including 
                                 – concerned only w/Header and Define                                     them in the program to be loaded.
                                   records                                                                 – In most cases there is a standard system 
                                 – PROGADDR is obtained from O/S                                             library that is used this way
                                 – CSADDR is set accordingly                                            • subroutines called by the program 
                                 – All external symbols are entered into                                  being loaded are automatically 
                                   External Symbol Table (Fig 3.11a)                                      retrieved from a library as they are 
                                 – Starting address and length of each CS                                 needed during linking.
                                   are determined
                                                                                    21                                                                        24
                                                                                                                                                                             4
The words contained in this file might help you see if this file matches what you are looking for:

...Loaders a loader is system program that performs the loading function systems programming many also support relocation linking others have separate linker and single exist on chapter since compilers assemblers linkers produce object code in same format outline basic functions design implementation of bringing an into memory fundamental for execution starting its e g absolute sic machine representation dependence independent features linkage editors perform before dynamic delaying until time introduction refer to section figure contains translated instructions data from operation very simple source no or specifies addresses where these items are be loaded pass brings check h record verify correct has been presented modifies so it read each t move can at address different indicated location originally specified jump combines two more begin programs supplies information needed allow references between them complex suitable xe typical those byte assembled given using found most modern comp...

no reviews yet
Please Login to review.