CS 550 Operating Systems Spring Process I

Size: px
Start display at page:

Download "CS 550 Operating Systems Spring Process I"

Transcription

1 CS 550 Operating Systems Spring 2018 Process I 1

2 Process Informal definition: A process is a program in execution. Process is not the same as a program. Program is a passive entity stored in the disk Process is an actively executing entity Program is just one component of a process. 2

3 Programs and Processes Process The running instantiation of a program, stored in RAM Program An executable file in long-term storage One-to-many relationship between program and processes 3

4 Programs How is a program (i.e., an executable binary file) formatted? main.c int buf[2] = {1, 2}; int main() { swap(); return 0; } swap.c extern int buf[]; int *bufp0 = &buf[0]; static int *bufp1; void swap() { int temp; bufp1 = &buf[1]; temp = *bufp0; *bufp0 = *bufp1; *bufp1 = temp; } 4

5 Programs How is a program (i.e., an executable binary file) formatted? The compiler compiles source code into relocatable object files. The linker links all necessary relocatable object files into an executable object file (i.e., the program). 5

6 Static Linking Programs are translated and linked using a compiler driver: unix> gcc -O2 -g -o p main.c swap.c unix>./p main.c swap.c Source files Translators (cpp, cc1, as) main.o Linker (ld) Translators (cpp, cc1, as) swap.o Separately compiled (relocatable) object files p Fully linked program (executable object file) (contains code and data for all functions defined in main.c and swap.c) 6

7 Executable Object files Object file formats vary from system to system DOS: MZ executables (*.exe) Named after Mark Zbikowski, a DOS developer Windows Portable Executable (PE, PE32+) (*.exe) Modified version of Unix COFF executable format Mac OSX: Mach object file format (Mach-O) Unix/Linux: Executable and Linkable Format (ELF) 7

8 Executable and Linkable Format (ELF) Standard binary format for object files for Unix and Unix-like systems on x86. Originally proposed by AT&T System V Unix Later adopted by BSD Unix variants and Linux One unified format for Relocatable object files (.o), Executable object files (a.out) Shared object files (.so) Generic name: ELF binaries 8

9 ELF Object File Format Elf header Word size, byte ordering, file type (.o, exec,.so), machine type, etc. Segment header table Page size, virtual addresses memory segments (sections), segment sizes..text section Code.rodata section Read only data.data section Initialized global variables.bss section Uninitialized global variables Block Started by Symbol Better Save Space Has section header but occupies no space ELF header Segment header table (required for executables).text section.rodata section.data section.bss section.symtab section.rel.txt section.rel.data section.debug section Section header table 9 0

10 ELF Header readelf -h p ELF Header: Magic: 7f 45 4c Class: ELF64 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: Advanced Micro Devices X86-64 Version: 0x1 Entry point address: 0x Start of program headers: 64 (bytes into file) Start of section headers: 6784 (bytes into file) Flags: 0x0 Size of this header: 64 (bytes) Size of program headers: 56 (bytes) Number of program headers: 9 Size of section headers: 64 (bytes) Number of section headers: 31 Section header string table index: 28 10

11 More Sources (ELF) ELF Wiki able_format ELF 101: 11

12 Programs When you double-click on a program (or use command line), how does the OS turn the file on disk into a process? Load time The loader creates a process for the program, loads the program to RAM, or more precisely, to the address space of the process, and starts executing the first instruction of the program. 12

13 Loading executable object files p is not a built-in shell command shell assumes p is an executable object file shell invokes the loader (some memory-resident OS code) to run the program p. Unix/Linux programs can invoke loader by calling the execve function (introduced later). The loader copies the code and data in the executable object file from disk into memory, and then runs the program by jumping to its first instruction, or the entry point. This process of copying the program into memory and then running it is known as loading. 13

14 So what else constitutes a process? Memory space (static, dynamic) Procedure call stack Registers and counters : Program counter, Stack pointer, General purpose registers Open files, connections 14

15 References Chapter 4 of OSTEP book Chapter 2 of the Tanenbaum s book Man pages for different system calls Try man 2 <syscall_name> E.g. man 2 exec Syscalls are normally listed in section 2 of the man page Google for Linux source code 15

16 Backups 16

Exercise Session 7 Computer Architecture and Systems Programming

Exercise Session 7 Computer Architecture and Systems Programming Systems Group Department of Computer Science ETH Zürich Exercise Session 7 Computer Architecture and Systems Programming Herbstsemester 2014 Review of last week s excersice structs / arrays in Assembler

More information

Systems Programming and Computer Architecture ( ) Timothy Roscoe

Systems Programming and Computer Architecture ( ) Timothy Roscoe Systems Group Department of Computer Science ETH Zürich Systems Programming and Computer Architecture (252-0061-00) Timothy Roscoe Herbstsemester 2016 AS 2016 Linking 1 12: Linking Computer Architecture

More information

C03c: Linkers and Loaders

C03c: Linkers and Loaders CISC 3320 MW3 C03c: Linkers and Loaders Hui Chen Department of Computer & Information Science CUNY Brooklyn College 2/4/2019 CUNY Brooklyn College: CISC 3320 OS 1 Outline Linkers and linking Loaders and

More information

Linking. Explain what ELF format is. Explain what an executable is and how it got that way. With huge thanks to Steve Chong for his notes from CS61.

Linking. Explain what ELF format is. Explain what an executable is and how it got that way. With huge thanks to Steve Chong for his notes from CS61. Linking Topics How do you transform a collection of object files into an executable? How is an executable structured? Why is an executable structured as it is? Learning Objectives: Explain what ELF format

More information

Lecture 16: Linking Computer Architecture and Systems Programming ( )

Lecture 16: Linking Computer Architecture and Systems Programming ( ) Systems Group Department of Computer Science ETH Zürich Lecture 16: Linking Computer Architecture and Systems Programming (252-0061-00) Timothy Roscoe Herbstsemester 2012 Last time: memory hierarchy L1/L2

More information

ELF (1A) Young Won Lim 10/22/14

ELF (1A) Young Won Lim 10/22/14 ELF (1A) Copyright (c) 2010-2014 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Example C program. 11: Linking. Why linkers? Modularity! Static linking. Why linkers? Efficiency! What do linkers do? 10/28/2013

Example C program. 11: Linking. Why linkers? Modularity! Static linking. Why linkers? Efficiency! What do linkers do? 10/28/2013 Example C program 11: Linking Computer Architecture and Systems Programming 252 61, Herbstsemester 213 Timothy Roscoe main.c int buf[2] = 1, 2; swap(); return ; swap.c static int *bufp = &buf[]; void swap()

More information

CSE2421 Systems1 Introduction to Low-Level Programming and Computer Organization

CSE2421 Systems1 Introduction to Low-Level Programming and Computer Organization Spring 2013 CSE2421 Systems1 Introduction to Low-Level Programming and Computer Organization Kitty Reeves TWRF 8:00-8:55am 1 Compiler Drivers = GCC When you invoke GCC, it normally does preprocessing,

More information

LINKING. Jo, Heeseung

LINKING. Jo, Heeseung LINKING Jo, Heeseung PROGRAM TRANSLATION (1) A simplistic program translation scheme m.c ASCII source file Translator p Binary executable object file (memory image on disk) Problems: - Efficiency: small

More information

Linking. Computer Systems Organization (Spring 2017) CSCI-UA 201, Section 3. Instructor: Joanna Klukowska

Linking. Computer Systems Organization (Spring 2017) CSCI-UA 201, Section 3. Instructor: Joanna Klukowska Linking Computer Systems Organization (Spring 2017) CSCI-UA 201, Section 3 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU) Mohamed Zahran (NYU) Example C

More information

Compiler Drivers = GCC

Compiler Drivers = GCC Compiler Drivers = GCC When you invoke GCC, it normally does preprocessing, compilation, assembly and linking, as needed, on behalf of the user accepts options and file names as operands % gcc O1 -g -o

More information

Example C Program The course that gives CMU its Zip! Linking March 2, Static Linking. Why Linkers? Page # Topics

Example C Program The course that gives CMU its Zip! Linking March 2, Static Linking. Why Linkers? Page # Topics 15-213 The course that gives CMU its Zip! Topics Linking March 2, 24 Static linking Dynamic linking Case study: Library interpositioning Example C Program main.c int buf[2] = 1, 2; int main() swap(); return

More information

A Simplistic Program Translation Scheme

A Simplistic Program Translation Scheme A Simplistic Program Translation Scheme m.c ASCII source file Translator p Binary executable object file (memory image on disk) Problems: Efficiency: small change requires complete recompilation Modularity:

More information

Computer Systems. Linking. Han, Hwansoo

Computer Systems. Linking. Han, Hwansoo Computer Systems Linking Han, Hwansoo Example C Program int sum(int *a, int n); int array[2] = {1, 2}; int sum(int *a, int n) { int i, s = 0; int main() { int val = sum(array, 2); return val; } main.c

More information

Linking February 24, 2005

Linking February 24, 2005 15-213 The course that gives CMU its Zip! Linking February 24, 2005 Topics Static linking Dynamic linking Case study: Library interpositioning 13-linking.ppt Example C Program main.c int buf[2] = {1, 2};

More information

Lecture 12-13: Linking

Lecture 12-13: Linking CSCI-UA.0201-003 Computer Systems Organization Lecture 12-13: Linking Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Source Code to Execution C source Assembly Assembly Compiler Assembly

More information

CSE 2421: Systems I Low-Level Programming and Computer Organization. Linking. Presentation N. Introduction to Linkers

CSE 2421: Systems I Low-Level Programming and Computer Organization. Linking. Presentation N. Introduction to Linkers CSE 2421: Systems I Low-Level Programming and Computer Organization Linking Read/Study: Bryant 7.1 7.10 Gojko Babić 11-15-2017 Introduction to Linkers Linking is the process of collecting and combining

More information

Computer Systems Organization

Computer Systems Organization Computer Systems Organization 1 Outline 2 A software view User Interface 3 How it works 4 The gcc compilation system 5 The gcc compilation system hello.c (source code) Pre-processor (cpp) hello.i (modified

More information

COMPILING OBJECTS AND OTHER LANGUAGE IMPLEMENTATION ISSUES. Credit: Mostly Bryant & O Hallaron

COMPILING OBJECTS AND OTHER LANGUAGE IMPLEMENTATION ISSUES. Credit: Mostly Bryant & O Hallaron COMPILING OBJECTS AND OTHER LANGUAGE IMPLEMENTATION ISSUES Credit: Mostly Bryant & O Hallaron Word-Oriented Memory Organization Addresses Specify Byte Locations Address of first byte in word Addresses

More information

Linking and Loading. CS61, Lecture 16. Prof. Stephen Chong October 25, 2011

Linking and Loading. CS61, Lecture 16. Prof. Stephen Chong October 25, 2011 Linking and Loading CS61, Lecture 16 Prof. Stephen Chong October 25, 2011 Announcements Midterm exam in class on Thursday 80 minute exam Open book, closed note. No electronic devices allowed Please be

More information

Revealing Internals of Linkers. Zhiqiang Lin

Revealing Internals of Linkers. Zhiqiang Lin CS 6V81-05: System Security and Malicious Code Analysis Revealing Internals of Linkers Zhiqiang Lin Department of Computer Science University of Texas at Dallas March 26 th, 2012 Outline 1 Background 2

More information

Sungkyunkwan University

Sungkyunkwan University Linking Case study: Library interpositioning main.c int buf[2] = {1, 2}; int main() { swap(); return 0; } swap.c extern int buf[]; int *bufp0 = &buf[0]; static int *bufp1; void swap() { int temp; } bufp1

More information

Link 2. Object Files

Link 2. Object Files Link 2. Object Files Young W. Lim 2017-09-23 Sat Young W. Lim Link 2. Object Files 2017-09-23 Sat 1 / 40 Outline 1 Linking - 2. Object Files Based on Oject Files ELF Sections Example Program Source Codes

More information

Link 3. Symbols. Young W. Lim Mon. Young W. Lim Link 3. Symbols Mon 1 / 42

Link 3. Symbols. Young W. Lim Mon. Young W. Lim Link 3. Symbols Mon 1 / 42 Link 3. Symbols Young W. Lim 2017-09-11 Mon Young W. Lim Link 3. Symbols 2017-09-11 Mon 1 / 42 Outline 1 Linking - 3. Symbols Based on Symbols Symbol Tables Symbol Table Examples main.o s symbol table

More information

Linking Oct. 15, 2002

Linking Oct. 15, 2002 15-213 The course that gives CMU its Zip! Topics Linking Oct. 15, 2002 Static linking Object files Static libraries Loading Dynamic linking of shared libraries class15.ppt Linker Puzzles int x; p1() {}

More information

Link 2. Object Files

Link 2. Object Files Link 2. Object Files Young W. Lim 2017-09-20 Wed Young W. Lim Link 2. Object Files 2017-09-20 Wed 1 / 33 Outline 1 Linking - 2. Object Files Based on Oject Files ELF Sections Example Program Source Codes

More information

Example C Program. Linking CS Instructor: Sanjeev Se(a. int buf[2] = {1, 2}; extern int buf[]; int main() { swap(); return 0; }

Example C Program. Linking CS Instructor: Sanjeev Se(a. int buf[2] = {1, 2}; extern int buf[]; int main() { swap(); return 0; } Linking Instructor: Sanjeev Se(a 1 Example C Program main.c int buf[2] = {1, 2; int main() { swap(); return 0; swap.c extern int buf[]; static int *bufp0 = &buf[0]; static int *bufp1; void swap() { int

More information

ELF (1A) Young Won Lim 3/24/16

ELF (1A) Young Won Lim 3/24/16 ELF (1A) Copyright (c) 21-216 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Generating Programs and Linking. Professor Rick Han Department of Computer Science University of Colorado at Boulder

Generating Programs and Linking. Professor Rick Han Department of Computer Science University of Colorado at Boulder Generating Programs and Linking Professor Rick Han Department of Computer Science University of Colorado at Boulder CSCI 3753 Announcements Moodle - posted last Thursday s lecture Programming shell assignment

More information

Executables and Linking. CS449 Spring 2016

Executables and Linking. CS449 Spring 2016 Executables and Linking CS449 Spring 2016 Remember External Linkage Scope? #include int global = 0; void foo(); int main() { foo(); printf( global=%d\n, global); return 0; } extern int

More information

Assembly Language Programming Linkers

Assembly Language Programming Linkers Assembly Language Programming Linkers November 14, 2017 Placement problem (relocation) Because there can be more than one program in the memory, during compilation it is impossible to forecast their real

More information

(Extract from the slides by Terrance E. Boult

(Extract from the slides by Terrance E. Boult What software engineers need to know about linking and a few things about execution (Extract from the slides by Terrance E. Boult http://vast.uccs.edu/~tboult/) A Simplistic Program Translation Scheme

More information

Computer Organization: A Programmer's Perspective

Computer Organization: A Programmer's Perspective A Programmer's Perspective Linking Gal A. Kaminka galk@cs.biu.ac.il A Simplistic Program Translation Scheme m.c ASCII source file Translator p Binary executable object file (memory image on disk) Problems:

More information

E = 2 e lines per set. S = 2 s sets tag. valid bit B = 2 b bytes per cache block (the data) CSE351 Inaugural EdiNon Spring

E = 2 e lines per set. S = 2 s sets tag. valid bit B = 2 b bytes per cache block (the data) CSE351 Inaugural EdiNon Spring Last Time Caches E = 2 e lines per set Address of word: t bits s bits b bits S = 2 s sets tag set index block offset data begins at this offset v tag 0 1 2 B 1 valid bit B = 2 b bytes per cache block (the

More information

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

Systems Programming. Fatih Kesgin &Yusuf Yaslan Istanbul Technical University Computer Engineering Department 18/10/2005 Systems Programming Fatih Kesgin &Yusuf Yaslan Istanbul Technical University Computer Engineering Department 18/10/2005 Outline How to assemble and link nasm ld gcc Debugging Using gdb; breakpoints,registers,

More information

ECE 471 Embedded Systems Lecture 4

ECE 471 Embedded Systems Lecture 4 ECE 471 Embedded Systems Lecture 4 Vince Weaver http://www.eece.maine.edu/ vweaver vincent.weaver@maine.edu 12 September 2013 Announcements HW#1 will be posted later today For next class, at least skim

More information

ECE 598 Advanced Operating Systems Lecture 10

ECE 598 Advanced Operating Systems Lecture 10 ECE 598 Advanced Operating Systems Lecture 10 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 22 February 2018 Announcements Homework #5 will be posted 1 Blocking vs Nonblocking

More information

CS631 - Advanced Programming in the UNIX Environment

CS631 - Advanced Programming in the UNIX Environment CS631 - Advanced Programming in the UNIX Environment Slide 1 CS631 - Advanced Programming in the UNIX Environment Shared Libraries Department of Computer Science Stevens Institute of Technology Jan Schaumann

More information

COS 318: Operating Systems

COS 318: Operating Systems COS 318: Operating Systems Overview Kai Li Computer Science Department Princeton University (http://www.cs.princeton.edu/courses/cos318/) Important Times Lectures 9/20 Lecture is here Other lectures in

More information

CS2141 Software Development using C/C++ Libraries

CS2141 Software Development using C/C++ Libraries CS2141 Software Development using C/C++ Compilation and linking /* p1.c */ int x; int z; main() { x=0; z=0; printf("f(3)=%d x=%d z=%d\n",f(3),x,z); } Code for int f(int) not available yet, nor printf()

More information

Linking. Today. Next time. Static linking Object files Static & dynamically linked libraries. Exceptional control flows

Linking. Today. Next time. Static linking Object files Static & dynamically linked libraries. Exceptional control flows Linking Today Static linking Object files Static & dynamically linked libraries Next time Exceptional control flows Fabián E. Bustamante, 2007 Example C program main.c void swap(); int buf[2] = {1, 2;

More information

ECE 498 Linux Assembly Language Lecture 1

ECE 498 Linux Assembly Language Lecture 1 ECE 498 Linux Assembly Language Lecture 1 Vince Weaver http://www.eece.maine.edu/ vweaver vincent.weaver@maine.edu 13 November 2012 Assembly Language: What s it good for? Understanding at a low-level what

More information

Executables and Linking. CS449 Fall 2017

Executables and Linking. CS449 Fall 2017 Executables and Linking CS449 Fall 2017 Remember External Linkage Scope? #include int global = 0; void foo(); int main() { } foo(); printf( global=%d\n, global); return 0; extern int

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 2: Hello World! Cristina Nita-Rotaru Lecture 2/ Fall 2013 1 Introducing C High-level programming language Developed between 1969 and 1973 by Dennis Ritchie at the Bell Labs

More information

CIT 595 Spring System Software: Programming Tools. Assembly Process Example: First Pass. Assembly Process Example: Second Pass.

CIT 595 Spring System Software: Programming Tools. Assembly Process Example: First Pass. Assembly Process Example: Second Pass. System Software: Programming Tools Programming tools carry out the mechanics of software creation within the confines of the operating system and hardware environment Linkers & Loaders CIT 595 Spring 2010

More information

COS 318: Operating Systems. Overview. Andy Bavier Computer Science Department Princeton University

COS 318: Operating Systems. Overview. Andy Bavier Computer Science Department Princeton University COS 318: Operating Systems Overview Andy Bavier Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall10/cos318/ Logistics Precepts: Tue: 7:30pm-8:30pm, 105 CS

More information

Process Environment. Pradipta De

Process Environment. Pradipta De Process Environment Pradipta De pradipta.de@sunykorea.ac.kr Today s Topic Program to process How is a program loaded by the kernel How does kernel set up the process Outline Review of linking and loading

More information

Virtual Memory Paging

Virtual Memory Paging Virtual Memory Paging An important task of a virtual-memory system is to relocate pages from physical memory out to disk Early UNIX systems swapped out the entire process at once Modern UNIX systems relay

More information

Operating Systems CMPSC 473. Process Management January 29, Lecture 4 Instructor: Trent Jaeger

Operating Systems CMPSC 473. Process Management January 29, Lecture 4 Instructor: Trent Jaeger Operating Systems CMPSC 473 Process Management January 29, 2008 - Lecture 4 Instructor: Trent Jaeger Last class: Operating system structure and basics Today: Process Management Why Processes? We have programs,

More information

CS 33. Linkers. CS33 Intro to Computer Systems XXV 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

CS 33. Linkers. CS33 Intro to Computer Systems XXV 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. CS 33 Linkers CS33 Intro to Computer Systems XXV 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. gcc Steps 1) Compile to start here, supply.c file to stop here: gcc -S (produces.s file) if not

More information

CS 201 Linking Gerson Robboy Portland State University

CS 201 Linking Gerson Robboy Portland State University CS 201 Linking Gerson Robboy Portland State University 1 15-213, F 02 A Simplistic Program Translation Scheme m.c ASCII source file Translator p Binary executable object file (memory image on disk) Problems:

More information

Draft. Chapter 1 Program Structure. 1.1 Introduction. 1.2 The 0s and the 1s. 1.3 Bits and Bytes. 1.4 Representation of Numbers in Memory

Draft. Chapter 1 Program Structure. 1.1 Introduction. 1.2 The 0s and the 1s. 1.3 Bits and Bytes. 1.4 Representation of Numbers in Memory Chapter 1 Program Structure In the beginning there were 0s and 1s. GRR 1.1 Introduction In this chapter we will talk about memory: bits, bytes and how data is represented in the computer. We will also

More information

CS356: Discussion #6 Assembly Procedures and Arrays. Marco Paolieri

CS356: Discussion #6 Assembly Procedures and Arrays. Marco Paolieri CS356: Discussion #6 Assembly Procedures and Arrays Marco Paolieri (paolieri@usc.edu) Procedures Functions are a key abstraction in software They break down a problem into subproblems. Reusable functionality:

More information

Compiler, Assembler, and Linker

Compiler, Assembler, and Linker Compiler, Assembler, and Linker Minsoo Ryu Department of Computer Science and Engineering Hanyang University msryu@hanyang.ac.kr What is a Compilation? Preprocessor Compiler Assembler Linker Loader Contents

More information

Cross Compiling. Real Time Operating Systems and Middleware. Luca Abeni

Cross Compiling. Real Time Operating Systems and Middleware. Luca Abeni Cross Compiling Real Time Operating Systems and Middleware Luca Abeni luca.abeni@unitn.it The Kernel Kernel OS component interacting with hardware Runs in privileged mode (Kernel Space KS) User Level Kernel

More information

Lecture Topics. Announcements. Today: Operating System Overview (Stallings, chapter , ) Next: Processes (Stallings, chapter

Lecture Topics. Announcements. Today: Operating System Overview (Stallings, chapter , ) Next: Processes (Stallings, chapter Lecture Topics Today: Operating System Overview (Stallings, chapter 2.1-2.4, 2.8-2.10) Next: Processes (Stallings, chapter 3.1-3.6) 1 Announcements Consulting hours posted Self-Study Exercise #3 posted

More information

CS240: Programming in C. Lecture 2: Overview

CS240: Programming in C. Lecture 2: Overview CS240: Programming in C Lecture 2: Overview 1 Programming Model How does C view the world? Stack Memory code Globals 2 Programming Model Execution mediated via a stack function calls and returns local

More information

u Linking u Case study: Library interpositioning

u Linking u Case study: Library interpositioning u Linking u Case study: Library interpositioning int sum(int *a, int n); int array[2] = {1, 2}; int sum(int *a, int n) { int i, s = 0; int main() { int val = sum(array, 2); return val; } main.c } for (i

More information

9/19/18. COS 318: Operating Systems. Overview. Important Times. Hardware of A Typical Computer. Today CPU. I/O bus. Network

9/19/18. COS 318: Operating Systems. Overview. Important Times. Hardware of A Typical Computer. Today CPU. I/O bus. Network Important Times COS 318: Operating Systems Overview Jaswinder Pal Singh and a Fabulous Course Staff Computer Science Department Princeton University (http://www.cs.princeton.edu/courses/cos318/) u Precepts:

More information

Linker Puzzles The course that gives CMU its Zip! Linking Mar 4, A Simplistic Program Translation Scheme. A Better Scheme Using a Linker

Linker Puzzles The course that gives CMU its Zip! Linking Mar 4, A Simplistic Program Translation Scheme. A Better Scheme Using a Linker 15-213 The course that gives CMU its Zi! Toics Static linking Object files Linking Mar 4, 2003 Static libraries Loading Dynamic linking of shared libraries Linker Puzzles 1() { 1() { 1() { 1() { int x=7;

More information

Process Address Spaces and Binary Formats

Process Address Spaces and Binary Formats Process Address Spaces and Binary Formats Don Porter Background We ve talked some about processes This lecture: discuss overall virtual memory organizafon Key abstracfon: Address space We will learn about

More information

ECE 598 Advanced Operating Systems Lecture 11

ECE 598 Advanced Operating Systems Lecture 11 ECE 598 Advanced Operating Systems Lecture 11 Vince Weaver http://www.eece.maine.edu/~vweaver vincent.weaver@maine.edu 23 February 2016 Announcements Homework #5 Posted Some notes, discovered the hard

More information

Department of Computer Science and Engineering Yonghong Yan

Department of Computer Science and Engineering Yonghong Yan Appendix A and Chapter 2.12: Compiler, Assembler, Linker and Program Execution CSCE 212 Introduction to Computer Architecture, Spring 2019 https://passlab.github.io/csce212/ Department of Computer Science

More information

ECE 471 Embedded Systems Lecture 5

ECE 471 Embedded Systems Lecture 5 ECE 471 Embedded Systems Lecture 5 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 13 September 2016 HW#2 is due Thursday It is going OK? Announcements 1 Homework #1 Review Characteristics

More information

Operating Systems CS3502 Spring 2018

Operating Systems CS3502 Spring 2018 Operating Systems CS3502 Spring 2018 Presented by Dr. Guoliang Liu Department of Computer Science College of Computing and Software Engineering Kennesaw State University Computer Systems See Appendix G

More information

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated CNIT 127: Exploit Development Ch 3: Shellcode Updated 1-30-17 Topics Protection rings Syscalls Shellcode nasm Assembler ld GNU Linker objdump to see contents of object files strace System Call Tracer Removing

More information

Soumava Ghosh The University of Texas at Austin

Soumava Ghosh The University of Texas at Austin Soumava Ghosh The University of Texas at Austin Agenda Overview of programs that perform I/O Linking, loading and the x86 model Modifying programs to perform I/O on the x86 model Interpreting and loading

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program. Language Translation Compilation vs. interpretation Compilation diagram Step 1: compile program compiler Compiled program Step 2: run input Compiled program output Language Translation compilation is translation

More information

Outline. 1 Background. 2 ELF Linking. 3 Static Linking. 4 Dynamic Linking. 5 Summary. Linker. Various Stages. 1 Linking can be done at compile.

Outline. 1 Background. 2 ELF Linking. 3 Static Linking. 4 Dynamic Linking. 5 Summary. Linker. Various Stages. 1 Linking can be done at compile. Outline CS 6V81-05: System Security and Malicious Code Analysis Revealing Internals of Linkers Zhiqiang Lin Department of Computer Science University of Texas at Dallas March 26 th, 2012 1 Background 2

More information

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

Linking and Loading. ICS312 - Spring 2010 Machine-Level and Systems Programming. Henri Casanova Linking and Loading ICS312 - Spring 2010 Machine-Level and Systems Programming Henri Casanova (henric@hawaii.edu) The Big Picture High-level code char *tmpfilename; int num_schedulers=0; int num_request_submitters=0;

More information

CS 550 Operating Systems Spring Process II

CS 550 Operating Systems Spring Process II CS 550 Operating Systems Spring 2018 Process II 1 Recap: Process Informal definition: A process is a program in execution. Process is not the same as a program. Program is a passive entity stored in the

More information

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18 PROCESS VIRTUAL MEMORY CS124 Operating Systems Winter 2015-2016, Lecture 18 2 Programs and Memory Programs perform many interactions with memory Accessing variables stored at specific memory locations

More information

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C. Structure Unix architecture users Functions of the System tools (shell, editors, compilers, ) standard library System call Standard library (printf, fork, ) OS kernel: processes, memory management, file

More information

Embedded Systems Programming

Embedded Systems Programming Embedded Systems Programming ES Development Environment (Module 3) Yann-Hang Lee Arizona State University yhlee@asu.edu (480) 727-7507 Summer 2014 Embedded System Development Need a real-time (embedded)

More information

238P: Operating Systems. Lecture 7: Basic Architecture of a Program. Anton Burtsev January, 2018

238P: Operating Systems. Lecture 7: Basic Architecture of a Program. Anton Burtsev January, 2018 238P: Operating Systems Lecture 7: Basic Architecture of a Program Anton Burtsev January, 2018 What is a program? What parts do we need to run code? Parts needed to run a program Code itself By convention

More information

Lecture 8: linking CS 140. Dawson Engler Stanford CS department

Lecture 8: linking CS 140. Dawson Engler Stanford CS department Lecture 8: linking CS 140 Dawson Engler Stanford CS department Today s Big Adventure Linking f.c gcc f.s as f.o c.c gcc c.s as c.o ld a.out how to name and refer to things that don t exist yet how to merge

More information

Reminder: compiling & linking

Reminder: compiling & linking Reminder: compiling & linking source file 1 object file 1 source file 2 compilation object file 2 library object file 1 linking (relocation + linking) load file source file N object file N library object

More information

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

CSCI341. Lecture 22, MIPS Programming: Directives, Linkers, Loaders, Memory CSCI341 Lecture 22, MIPS Programming: Directives, Linkers, Loaders, Memory REVIEW Assemblers understand special commands called directives Assemblers understand macro commands Assembly programs become

More information

Week 5 Lecture 3. Compiler Errors

Week 5 Lecture 3. Compiler Errors Lecture 3 Compiler Errors Agile Development Backlog of stories defines projects Backlog contains all of the requirements currently known Stories define features of the project Three elements: feature user,

More information

High Performance Computing Lecture 1. Matthew Jacob Indian Institute of Science

High Performance Computing Lecture 1. Matthew Jacob Indian Institute of Science High Performance Computing Lecture 1 Matthew Jacob Indian Institute of Science Agenda 1. Program execution: Compilation, Object files, Function call and return, Address space, Data & its representation

More information

2012 LLVM Euro - Michael Spencer. lld. Friday, April 13, The LLVM Linker

2012 LLVM Euro - Michael Spencer. lld. Friday, April 13, The LLVM Linker lld Friday, April 13, 2012 The LLVM Linker What is lld? A system linker Produce final libraries and executables, no other tools or runtime required Understands platform ABI What is lld? A system linker

More information

Linking Oct. 26, 2009"

Linking Oct. 26, 2009 Linking Oct. 26, 2009" Linker Puzzles" int x; p1() {} p1() {} int x; p1() {} int x; p2() {} int x; int y; p1() {} int x=7; int y=5; p1() {} double x; p2() {} double x; p2() {} int x=7; p1() {} int x; p2()

More information

Link 4. Relocation. Young W. Lim Wed. Young W. Lim Link 4. Relocation Wed 1 / 22

Link 4. Relocation. Young W. Lim Wed. Young W. Lim Link 4. Relocation Wed 1 / 22 Link 4. Relocation Young W. Lim 2017-09-13 Wed Young W. Lim Link 4. Relocation 2017-09-13 Wed 1 / 22 Outline 1 Linking - 4. Relocation Based on Relocation Relocation Entries Relocating Symbol Reference

More information

A software view. Computer Systems. The Compilation system. How it works. 1. Preprocesser. 1. Preprocessor (cpp)

A software view. Computer Systems. The Compilation system. How it works. 1. Preprocesser. 1. Preprocessor (cpp) A software view User Interface Computer Systems MTSU CSCI 3240 Spring 2016 Dr. Hyrum D. Carroll Materials from CMU and Dr. Butler How it works hello.c #include int main() { printf( hello, world\n

More information

Today s Big Adventure

Today s Big Adventure Today s Big Adventure - How to name and refer to things that don t exist yet - How to merge separate name spaces into a cohesive whole Readings - man a.out & elf on a Solaris machine - run nm or objdump

More information

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University Main Memory CISC3595, Spring 2015 X. Zhang Fordham University 1 Memory Management! Background!! Contiguous Memory Allocation!! Paging!! Structure of the Page Table!! Segmentation!! Example: The Intel Pentium

More information

EE458 - Embedded Systems Lecture 4 Embedded Devel.

EE458 - Embedded Systems Lecture 4 Embedded Devel. EE458 - Embedded Lecture 4 Embedded Devel. Outline C File Streams References RTC: Chapter 2 File Streams man pages 1 Cross-platform Development Environment 2 Software available on the host system typically

More information

Today s Big Adventure

Today s Big Adventure 1/34 Today s Big Adventure - How to name and refer to things that don t exist yet - How to merge separate name spaces into a cohesive whole Readings - man a.out & elf on a Solaris machine - run nm or objdump

More information

Tools > Compiling & Debugging

Tools > Compiling & Debugging Mach-O Programming Topics Tools > Compiling & Debugging 2006-11-28 Apple Inc. 2003, 2006 Apple Computer, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system,

More information

CSE506: Operating Systems CSE 506: Operating Systems

CSE506: Operating Systems CSE 506: Operating Systems CSE 506: Operating Systems What Software Expects of the OS What Software Expects of the OS Shell Memory Address Space for Process System Calls System Services Launching Program Executables Shell Gives

More information

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview Today CSCI 4061 Introduction to s Instructor: Abhishek Chandra OS Evolution Unix Overview Unix Structure Shells and Utilities Calls and APIs 2 Evolution How did the OS evolve? Generation 1: Mono-programming

More information

COS 318: Operating Systems. Overview. Prof. Margaret Martonosi Computer Science Department Princeton University

COS 318: Operating Systems. Overview. Prof. Margaret Martonosi Computer Science Department Princeton University COS 318: Operating Systems Overview Prof. Margaret Martonosi Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall11/cos318/ Announcements Precepts: Tue (Tonight)!

More information

o Code, executable, and process o Main memory vs. virtual memory

o Code, executable, and process o Main memory vs. virtual memory Goals for Today s Lecture Memory Allocation Prof. David August COS 217 Behind the scenes of running a program o Code, executable, and process o Main memory vs. virtual memory Memory layout for UNIX processes,

More information

CS 550 Operating Systems Spring Process III

CS 550 Operating Systems Spring Process III CS 550 Operating Systems Spring 2018 Process III 1 Recap: Memory Layout of a typical process MAX Stack Function Call Arguments, Return Address, Return Values Gap Heap Data Dynamically allocated memory

More information

Midterm. Median: 56, Mean: "midterm.data" using 1:2 1 / 37

Midterm. Median: 56, Mean: midterm.data using 1:2 1 / 37 30 Midterm "midterm.data" using 1:2 25 20 15 10 5 0 0 20 40 60 80 100 Median: 56, Mean: 53.13 1 / 37 Today s Big Adventure f.c gcc f.s as f.o c.c gcc c.s as c.o ld a.out How to name and refer to things

More information

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition 1 Linking 15-213: Introduction to Computer Systems 13 th Lecture, October 10th, 2017 Instructor: Randy Bryant 2 Today Linking Motivation What it does How it works Dynamic linking Case study: Library interpositioning

More information

CSE506: Operating Systems CSE 506: Operating Systems

CSE506: Operating Systems CSE 506: Operating Systems CSE 506: Operating Systems What Software Expects of the OS What Software Expects of the OS Memory System Calls System Services Launching Program Executables Shell Memory Abstraction CSE506: Operating Systems

More information

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition Chapter 8: Memory Management 8.1 Silberschatz, Galvin and Gagne 2009 Background Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are

More information

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview Today CSCI 4061 Introduction to s Instructor: Abhishek Chandra OS Evolution Unix Overview Unix Structure Shells and Utilities Calls and APIs 2 Evolution How did the OS evolve? Dependent on hardware and

More information