Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.

Slides:



Advertisements
Similar presentations
Chapter 3 Basic Input/Output
Advertisements

Part IV: Memory Management
Memory Protection: Kernel and User Address Spaces  Background  Address binding  How memory protection is achieved.
Chapter 9 TRAP Routines and Subroutines. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 9-2 Subroutines.
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3 J. Levine: Linkers & Loaders
Linkage Editors Difference between a linkage editor and a linking loader: Linking loader performs all linking and relocation operations, including automatic.
Linking & Loading CS-502 Operating Systems
Chapter 3 Loaders and Linkers
Chapter 3 Loaders and Linkers. Purpose and Function Places object program in memory Linking – Combines 2 or more obj programs Relocation – Allows loading.
Loaders and Linkers CS 230 이준원. 2 Overview assembler –generates an object code in a predefined format »COFF (common object file format) »ELF (executable.
SYSTEM PROGRAMMING & SYSTEM ADMINISTRATION
Linkers and Loaders 1 Linkers & Loaders – A Programmers Perspective.
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
The Functions and Purposes of Translators Code Generation (Intermediate Code, Optimisation, Final Code), Linkers & Loaders.
CS 31003: Compilers ANIRUDDHA GUPTA 11CS10004 G2 CLASS DATE : 24/07/2013.
Computer Organization CS224 Fall 2012 Lesson 12. Synchronization  Two processors or threads sharing an area of memory l P1 writes, then P2 reads l Data.
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
Lab6 – Debug Assembly Language Lab
1 Machine-Independent Features Automatic Library Search automatically incorporate routines from a subprogram library Loading Options.
An introduction to systems programming
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Copyright Arshi Khan1 System Programming Instructor Arshi Khan.
Chapter 91 Memory Management Chapter 9   Review of process from source to executable (linking, loading, addressing)   General discussion of memory.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
System Calls 1.
Separate Assembly allows a program to be built from modules rather than a single source file.
MIPS coding. SPIM Some links can be found such as:
Improving Program Performance Function Visibility in z/TPF C++ Load Modules October 2, /2/20151American Express Public.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
Objective At the conclusion of this chapter you will be able to:
CE Operating Systems Lecture 3 Overview of OS functions and structure.
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Static Shared Library. Non-shared v.s. Shared Library A library is a collection of pre-written function calls. Using existing libraries can save a programmer.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
Efficient software-based fault isolation Robert Wahbe, Steven Lucco, Thomas Anderson & Susan Graham Presented by: Stelian Coros.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 31 Memory Management.
CSc 453 Linking and Loading
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Hello world !!! ASCII representation of hello.c.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 – Loaders.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
7-Nov Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct lecture23-24-hll-interrupts 1 High Level Language vs. Assembly.
Binding & Dynamic Linking Presented by: Raunak Sulekh(1013) Pooja Kapoor(1008)
Introduction to Operating Systems Concepts
Lecture 3 Translation.
System Programming and administration
System Programming and administration
Computer Architecture
The University of Adelaide, School of Computer Science
Linking & Loading.
Chapter 8 Main Memory.
Separate Assembly allows a program to be built from modules rather than a single source file assembler linker source file.
CS-3013 Operating Systems C-term 2008
Loaders and Linkers: Features
Machine Independent Features
Memory Management Tasks
Computer Organization and Design Assembly & Compilation
The Assembly Language Level
Linking & Loading CS-502 Operating Systems
Linking & Loading CS-502 Operating Systems
An introduction to systems programming
Program Assembly.
Chapter 3 Loaders and Linkers
Presentation transcript:

Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook

Processor I/O Debugger System Software

 Assembler, compiler, and linker are tools for generating object programs  Loader transfers programs into memory and handles execution initiation/termination  Debugger identifies programming errors  I/O and other tasks can be programmed in multiple languages  Operating system manages everything

 We discussed this earlier in the course; review it if you have forgotten.

 Can partition one program into multiple files  Can also use subroutines defined by others  Let assembler process each file separately, making list of unknown external names  Object file augmented with list of names and list of instructions with external references  Programmer must also export names from an object file that could be used with other files

 Combines object files into object program  Constructs map of full program in memory using length information in each object file  Map determines addresses of all names:  Relocation information used to update absolute references  External names matched with exported names  Instructions referring to external names are finalized with addresses determined by map  Unmatched names are reported as errors

7 We will work through the details of linking in class

8 Internal SymbolsExternal Symbols SymbolValueSymbolReference List @Loc48 GET_JTAG32 Global (Exported): _start Code Length: 56 Bytes Internal SymbolsExternal Symbols SymbolValueSymbolReference List PUT_JTAG0 END_PUT24 TEXT_STRING36 Global (Exported): PUT_JTAG, TEXT_STRING Code Length: 61 Bytes (36 Bytes of text + 25 Bytes of data) File 1: File 2:

9

1. Placement of Object Files: 10 0: 55: 56: 116: Obj1 Obj2

2. Resolving References: Add offset of 56 to internal symbols in Obj2 referenced in Obj1: TEXT_STRING (original value = 36) will have new value = = 92 Hence the in Obj1 will be 92 PUT_JTAG (original value = 0) will have new value = 0+56 = 56 Hence in Obj1 will be 56 11

3. After resolving all the references, the linker is able to create a single executable object file. 12

1. Place object-code modules  Location of object code arbitrary unless specified by ORIGIN specification by user  Order of placement does not matter 2. Determine the value of all internally defined symbols in each module. 3. Resolve external references using known values determined in Step 2. If there are still unresolved references, report error. 13

 Subroutines that are useful in one program are often useful in other programs  Separate file assembly and linking enables reuse of source files with these subroutines  Alternatively (common case), generate object files once and use archiver to collect them into a library file  Library includes name information to aid in resolving references from calling program

 Static: Before execution starts, Linker/Loader identifies all the routines that are called any where in the linked source files and links them.  Dynamic: Delayed linking/loading at execution time.  Static linking is fast but:  Library routines become part of executable code and cannot be updated without linking again.  Loads routines in the library that are called anywhere in the executable, even if those calls are not executed 15

 Non-local routines linked at run time when called (lazy procedure linkage)  Implementation depends on indirection. 16

 On first call:  The non-local routine calls a dummy routine at the end of the program;  One dummy routine per non-local routine, contains an indirect jump.  The dummy routine puts a number in a register to identify the desired library routine and then jumps to the dynamic linker/loader.  The linker loader finds the desired routine, remaps it, and changes the address in the indirect jump location to point to that routine. It then jumps to it.  On subsequent calls to the routine, the program uses the indirect jump to go directly to the routine, bypassing the dynamic linker/loader 17

18  Requires extra space for the information needed for dynamic linking but does not require whole libraries to be copied or linked.  Substantial overhead on first call; only a single indirect jump thereafter.  No overhead for return.  Commonly used today – DLL (Windows) or Shared Objects (Unix) 3 Dummy Routine puts ID of the DLL Routine 2 Indirect Jump 1 Call to a non-local Routine 4 DLL Routine linked (remapp -ed) 5 Indirect jump address changed to DLL Routine by Linker/Loader

 Advantages  Often-used libraries (for example the standard system libraries) need to be stored in only one location, not duplicated in every single binary.  If an error in a library function is corrected by replacing the library, all programs using it dynamically will benefit from the correction after restarting them. Programs that included this function by static linking would have to be re-linked first.  Disadvantages  Known on the Windows platform as "DLL Hell", an incompatible updated DLL will break executables that depended on the behavior of the previous DLL.DLL Hell  A program, together with the libraries it uses, might be certified (e.g. as to correctness, documentation requirements, or performance) as a package, but not if components can be replaced. (This also argues against automatic OS updates in critical systems; in both cases, the OS and libraries form part of a qualified environment.) 19

 Loader invoked when user types command or clicks on icon in graphical user interface  User input identifies object file on disk  Object file has information on starting location in memory and length of program  Loader transfers object program from disk to memory and branches to starting address  At program termination, loader recovers space in memory and awaits next command

 Programming errors, or bugs, can cause an object program to produce incorrect results  The debugger enables the programmer to identify such errors at execution time  Execution can be stopped at points of interest  At such points, debugger accepts commands to display contents of registers or memory  Execution resumed until next point of interest

 The debugger can use trace mode interrupts  Service routine invoked after each instruction to enable user to inspect registers/memory  Trace mode disabled within debugger, then re-enabled upon return from interrupt  Breakpoints involve placing software- interrupt instruction in program to enter debugger  Old instruction restored to resume execution

23 Assume the user sets a breakpoint at the instruction at LOOP in the debugger.

24 In response, the debugger installs a software trap at LOOP, saving the original instruction at that location.

25 When execution reaches LOOP the software trap brings control back to the debugger …

26 The debugger restores the original instruction at LOOP, installs software trap at the following instruction and saves that instruction

27 When the second software trap occurs at location after LOOP …

28 The debugger restores the instruction at the location after LOOP, sets a software trap at LOOP, saving the instruction at that location. Now we are back to the conditions prevailing after initial set up.

 Discussed the low-level systems programs used for generating, running, and debugging programs.  Will only briefly touch on two other important systems programs: compilers and OS. 29