The Big Picture. Linker. Module 1. Module 2. One Module. Module 3. Module 4

Similar documents
King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

Linking and Loading. ICS312 - Spring 2010 Machine-Level and Systems Programming. Henri Casanova

Compiler, Assembler, and Linker

JAVA PROGRAMMING (340)

New York University Computer Science Department Courant Institute of Mathematical Sciences

CSCI341. Lecture 22, MIPS Programming: Directives, Linkers, Loaders, Memory

ENCE 3241 Data Lab. 60 points Due February 19, 2010, by 11:59 PM

Unsigned Binary Integers

Unsigned Binary Integers

Programming Languages

Multiplying and Dividing by Powers of 10

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

CS 361 Computer Systems Fall 2017 Homework Assignment 1 Linking - From Source Code to Executable Binary

Assignment 4. Overview. Prof. Stewart Weiss. CSci 335 Software Design and Analysis III Assignment 4

PL Recitation 9/21/2010

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

The Assembly Language Level. Chapter 7

This test is not formatted for your answers. Submit your answers via to:

12: Memory Management

CS420: Operating Systems

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

Learning Log Title: CHAPTER 3: PORTIONS AND INTEGERS. Date: Lesson: Chapter 3: Portions and Integers

This homework is due by 11:59:59 PM on Thursday, October 12, 2017.

Requirements, Partitioning, paging, and segmentation

New York University Computer Science Department Courant Institute of Mathematical Sciences

Programming Assignment HW5: CPU Scheduling draft v04/02/18 4 PM Deadline April 7th, 2018, 5 PM. Late deadline with penalty April 9th, 2018, 5 PM

Virtual machines. Virtual machines. Abstractions for computers. Abstractions for computers. Virtual machines

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

COS 126 General Computer Science Fall Exam 1

CSCI 4000 Assignment 4

Student Drop Box User Guide. Student User Guide for Submission of Assessments Online

Name Date Class. MM', and NN' on the graph for Problem 2, where would the lines intersect? (, ) This point is called the

Paging, and segmentation

and denominators of two fractions. For example, you could use

Programming Assignment HW4: CPU Scheduling v03/17/19 6 PM Deadline March 28th, 2019, 8 PM. Late deadline with penalty March 29th, 2019, 8 PM

EL2310 Scientific Programming

CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection

Instructions Common Table Ministry Proposal Form

EECE 321: Computer Organization

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Homework 4 (document version 1.1) Sockets and Server Programming using C

JAVA PROGRAMMING (340)

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++

Memory Management. COMP755 Advanced Operating Systems

Operating Systems. 09. Memory Management Part 1. Paul Krzyzanowski. Rutgers University. Spring 2015

COMP26120 Academic Session: Lab Exercise 2: Input/Output; Strings and Program Parameters; Error Handling

CSE Theory of Computing Fall 2017 Project 3: K-tape Turing Machine

Chapter 3 Loaders and Linkers -- Loader Design Options

Principles of Compiler Design

COMPILER DESIGN LEXICAL ANALYSIS, PARSING

Code Check TM Software Requirements Specification

Introduction to Computer Systems COMP-273 Assignment #1 Due: September 24, 2009 on Web CT at 23:55

CIS 2168: Assignment #9

Memory Management. Memory Management

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

GUIDELINE ON HOW TO FILL IN THE APPLICATION FORM. Operational programme Slovenia-Hungary

Background. Contiguous Memory Allocation

Fall CSEE W4119 Computer Networks Programming Assignment 1 - Simple Chat Application

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Homework 3 (document version 1.2) Multi-threading in C using Pthreads

Systems Programming. Fatih Kesgin &Yusuf Yaslan Istanbul Technical University Computer Engineering Department 18/10/2005

Registrar Data Instructions

PSU Object Reports: Introduction. Object Reports: Introduction. Understanding Object Reports. Creating Your Object Report. A Time-Saving Process

Programming Project 4: COOL Code Generation

Assignment Manager. Change Edit Mode to On if it is not already by clicking on the option at the top right of the window.

Introduction List/Modify Users... 2 Send Change Password... 3 Properties Enroll User... 3 Remove Users from Course...

ELEG3924 Microprocessor

Introduction. Linking, which combines two or more separate object programs and supplies the information needed to allow references between them.

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

Team 1. Common Questions to all Teams. Team 2. Team 3. CO200-Computer Organization and Architecture - Assignment One

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1

General Instructions. You can use QtSpim simulator to work on these assignments.

ZedBoard Tutorial. EEL 4720/5721 Reconfigurable Computing

CS2304-SYSTEM SOFTWARE 2 MARK QUESTION & ANSWERS. UNIT I INTRODUCTION

ELEG3923 Microprocessor Ch.2 Assembly Language Programming

Project 1. due date Sunday July 8, 2018, 12:00 noon

Main Memory (Part I)

New York University Computer Science Department Courant Institute of Mathematical Sciences

Assignment Kit for Program 1

Memory Management. Before We Begin. Process s Memory Address Space. Process Memory. CSE 120: Principles of Operating Systems.

CS 2704 Project 3 Spring 2000

CSE Theory of Computing Fall 2017 Project 1-SAT Solving

John Hancock file specifications

Getting Started with Moodle 2.0

The A ssembly Assembly Language Level Chapter 7 1

CS 61C: Great Ideas in Computer Architecture. (Brief) Review Lecture

Lecture 7. Memory Management

Problem Set 6 Audio Programming Out of 40 points. All parts due at 8pm on Thursday, November 29, 2012

CS1100: Excel Lab 1. Problem 1 (25 Points) Filtering and Summarizing Data

Correction and Replacement Returns

Using C++, design an Abstract Data Type class named MyGrades. The class must have the following private members :

Microsoft Outlook 2007 Contacts

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

CMSC 311 Spring 2010 Lab 1: Bit Slinging

Registrar Data Instructions

CS 2604 Minor Project 1 DRAFT Fall 2000

Slide Set 4. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

INFO 2313: Project. School of Business Kwantlen Polytechnic University. Nov 19, 2016 It is due at 12:00 PM (noon) on Sunday, Dec 4, 2016

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine

Moodle Morsels from Sandy & Inkie. b. Click (Log in) on the upper right c. You will use your stpsb login, which is how you login to a computer

Transcription:

Linker

The Big Picture Module 1 Module 2 Module 3 Linker One Module Module 4

The Big Picture Module 1 Module 2 Module 3 Linker One Module Module 4 You need to design this!

Two Things Relocation: Translate from relative address to absolute address Resolve: Get the absolute address of external variables

Assumptions A machine with memory size of 6 words Each word has an address (word-addressable) 1 word = 4 decimal digits Leftmost digit is opcode The other 3 are addresses Each module is divided into 3 parts Definition list Use list Code

1 xy 2 2 z xy 5 R 14 I 5678 E 2 R 82 E 71

Def list Use list 1 xy 2 2 z xy 5 R 14 I 5678 E 2 R 82 E 71 Code

Number of variables in this module Def list 1 xy 2 Relative address from the start of THIS module Variable name

Use list Number of variables used in this module 2 z xy List of variables (some are local and some are externals)

Code 5 R 14 I 5678 E 2 R 82 E 71 Module size The code: I : Immediate (unmodified by linker) A: Absolute (unmodified by linker) R: Relative (needs relocation) E: External (needs to be resolved)

Code 5 R 14 I 5678 E 2 R 82 E 71 Module size The code: I : Immediate (unmodified by linker) A: Absolute (unmodified by linker) R: Relative (needs relocation) E: External (needs to be resolved) The right most 3 digits designate the variable in the use list, starting from. So here it means the second variable

What You Need To Do Process all the modules twice First Pass: Calculate base address for each module Generate symbol table with all variables from all modules and their absolute address Second Pass: Relocate Relative addresses (instructions with R in front of them) Resolve external reference (instructions with E in front of them)

Example 1 xy 2 2 z xy 5 R 14 I 5678 E 2 R 82 E 71 6 R 81 E 1 E 1 E 3 R 12 A 11 2 R 51 E 4 2 2 xy z 3 A 8 E 11 E 2

Example 1 xy 2 2 z xy 5 R 14 I 5678 E 2 R 82 E 71 6 R 81 E 1 E 1 E 3 R 12 A 11 2 R 51 E 4 2 2 xy z 3 A 8 E 11 E 2 After First Pass Symbol Table xy=2 z=15 Module 1 base adrs: Module 2 base adrs: 5 Module 3 base adrs: 11 Module 4 base adrs: 13

Relocating Relative Addresses Example During Second Pass 1 xy 2 2 z xy 5 R 14 I 5678 E 2 R 82 E 71 6 R 81 E 1 E 1 E 3 R 12 A 11 2 R 51 E 4 2 2 xy z 3 A 8 E 11 E 2 Symbol Table xy=2 z=15 Module 1 base adrs: Module 2 base adrs: 5 Module 3 base adrs: 11 Module 4 base adrs: 13

Relocating Relative Addresses Example During Second Pass 1 xy 2 2 z xy 5 R 14 I 5678 E 2 R 82 E 71 6 R 86 E 1 E 1 E 3 R 17 A 11 2 R 512 E 4 2 2 xy z 3 A 8 E 11 E 2 Symbol Table xy=2 z=15 Module 1 base adrs: Module 2 base adrs: 5 Module 3 base adrs: 11 Module 4 base adrs: 13

Resolving Absolute Addresses Example During Second Pass 1 xy 2 2 z xy 5 R 14 I 5678 E 2 R 82 E 71 6 R 86 E 1 E 1 E 3 R 17 A 11 2 R 512 E 4 2 2 xy z 3 A 8 E 11 E 2 Symbol Table xy=2 z=15 Module 1 base adrs: Module 2 base adrs: 5 Module 3 base adrs: 11 Module 4 base adrs: 13

Resolving Absolute Addresses Example During Second Pass 1 xy 2 2 z xy 5 R 14 I 5678 E 215 R 82 E 72 6 R 86 E 115 E 115 E 315 R 17 A 11 2 R 512 E 415 2 2 xy z 3 A 8 E 115 E 22 Symbol Table xy=2 z=15 Module 1 base adrs: Module 2 base adrs: 5 Module 3 base adrs: 11 Module 4 base adrs: 13

Example 1 xy 2 2 z xy 5 R 14 I 5678 E 215 R 82 E 72 6 R 86 E 115 E 115 E 315 R 17 A 11 2 R 512 E 415 2 2 xy z 3 A 8 E 115 E 22 Final Output xy=2 z=15 : 14 1: 5678 2: 215 3: 82 4: 72 5: 86 6: 115 7: 115 8: 315 9: 17 1: 11 11: 512 12: 415 13: 8 14: 115 15: 22

Your Linker Must Also Catch The Following Errors If a symbol is multiply defined, print an error message specifying the variable and exit. If a symbol is used but not defined, print an error message specifying the value and exit. If a symbol is defined but not used, print a warning message specifying the value and continue. If an address appearing in a definition exceeds the size of the module, print an error message specifying the given address and the module size and exit. If an external address is too large to reference an entry in the use list, print an error message specifying the variable and exit. If a symbol appears in a use list but it not actually used in the module (i.e., not referred to in an E-type address), print a warning message and continue. If an absolute address exceeds the size of the machine, print an error message specifying that address and exit. If a relative address exceeds the size of the module, print an error specifying that address and exit.

What To Submit Your source code A readme file that specifies: How to compile your code How to run your code Put all your files in one zip file with the following name: lastname-firstname-linker.zip Email the file to the graders with subject line: linker project submission