Link 2. Object Files

Size: px
Start display at page:

Download "Link 2. Object Files"

Transcription

1 Link 2. Object Files Young W. Lim Wed Young W. Lim Link 2. Object Files Wed 1 / 33

2 Outline 1 Linking - 2. Object Files Based on Oject Files ELF Sections Example Program Source Codes Relocatable Object Files Executable Object Files Object File Comparsion Young W. Lim Link 2. Object Files Wed 2 / 33

3 Based on "Self-service Linux: Mastering the Art of Problem Determination", Mark Wilding "Computer Architecture: A Programmer s Perspective", Bryant & O Hallaron I, the copyright holder of this work, hereby publish it under the following licenses: GNU head 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 published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License. CC BY SA This file is licensed under the Creative Commons Attribution ShareAlike 3.0 Unported License. In short: you are free to share and make derivative works of the file under the conditions that you appropriately attribute it, and that you distribute it only under a license compatible with this one. Young W. Lim Link 2. Object Files Wed 3 / 33

4 Object Files Relocatable object file Executable object file Shared object file Young W. Lim Link 2. Object Files Wed 4 / 33

5 Relocatable Object Files Relocatable object file contains binary code and data in a form that can be combined with other relocatable object files at compile time to create an executable object file Young W. Lim Link 2. Object Files Wed 5 / 33

6 Executable Object Files Shared object file a special relocatable object file that can be loaded into memory and linke dynamically at either load time or run time Young W. Lim Link 2. Object Files Wed 6 / 33

7 Types of Excutable Object Files out COFF (Common Object File format) PE (Portable Executable format) ELF (Executable and Linkable Format) Young W. Lim Link 2. Object Files Wed 7 / 33

8 ELF Relocatable Object Files Linking View ELF Header Program Header Table Section 1 Section 2 Section Section n Section Header Table Possible Section Types.text.rodata.data.bss.symtab.rel.text.rel.data.debug.line.strtab Program Header Table is optional Young W. Lim Link 2. Object Files Wed 8 / 33

9 ELF Header 16-byte sequence : the word size and byte ordering information that allows a linker to parse and interpret the object file the size of ELF header the object file type (relocatble, executable, shared) the machine type Young W. Lim Link 2. Object Files Wed 9 / 33

10 Program Header Table 1 tells the system how to create a process image executable files must have program header table relocatable files do not need (optional) need for execution 1 Young W. Lim Link 2. Object Files Wed 10 / 33

11 Section Header Table 1 identifies all the sections in the file every section in the file has an entry in the section header table an array of structures with an index the file offset of the section header table the size and number of entries in the section header table contains a fixed sized entry for each section in the object file relocatable files must have program header table executable files do not need (optional) need for linking Young W. Lim Link 2. Object Files Wed 11 / 33

12 Memory Map environment vars commandline args stack heap uninit.bss init.data text Young W. Lim Link 2. Object Files Wed 12 / 33

13 .text,.rodata.text the machine code.rodata read only data string constants jump tables for swtich statements Young W. Lim Link 2. Object Files Wed 13 / 33

14 .data,.bss.data initialized global variables initialized static variables no local variables (on the stack, at the run time) occupy actual space in the object file.bss uninitialized global variables uninitialized static variables no local variables (on the stack, at the run time) no actual space in the object file just a place holder for space efficiency Young W. Lim Link 2. Object Files Wed 14 / 33

15 .symtab.symtab symbol table information about functions and global variables regardless of -g compile switch every relocatable object file has a symbol table in.symtab the symbol table in.symtab no entries for local variables the symbol table inside a compiler does have entries for local variables Young W. Lim Link 2. Object Files Wed 15 / 33

16 .rel.text.rel.text locations in the text section will be changed when linker combines object files instructions that need to be changed: calls an external function references a global variable instructions that calls local functions : no need to be changed executable object files do not need relocation information is usually omitted without an explicit instruction to include it Young W. Lim Link 2. Object Files Wed 16 / 33

17 .rel.data.rel.data relocation information for any global variables that are referenced or defined by the module any initialized global variable will need to be modified whose initial value is the address of a global variable externally defined function Young W. Lim Link 2. Object Files Wed 17 / 33

18 .debug.debug a debugging symbole table entries local variables typedefs global variables only present when compiled with the -g option Young W. Lim Link 2. Object Files Wed 18 / 33

19 .line.line a mapping between line numbers and machine code instructions in the.text only present when compiled with the -g option Young W. Lim Link 2. Object Files Wed 19 / 33

20 .strtab.strtab a string table for the symbol tables in the.symtab and.debug sections and for the section names in the section headers a string table is a sequence of null-terminated character string Young W. Lim Link 2. Object Files Wed 20 / 33

21 c source code // swap.c // main.c void swap(); int buf[2] = {1, 2}; int main() { swap(); extern int buf[]; int *p0 = &buf[0]; int *p1; void swap() { int tmp; p1 = &buf[1]; } return 0; tmp = *p0; *p0 = *p1; *p1 = tmp; } Young W. Lim Link 2. Object Files Wed 21 / 33

22 main source and assembly codes // main.c void swap(); int buf[2] = {1, 2}; int main() { swap(); return 0; } <main>: 0: lea 0x4(%esp),%ecx 4: and $0xfffffff0,%esp 7: pushl -0x4(%ecx) a: push %ebp b: mov %esp,%ebp d: push %ecx e: sub $0x4,%esp 11: call 12 <main+0x12> 16: add $0x4,%esp 19: xor %eax,%eax 1b: pop %ecx 1c: pop %ebp 1d: lea -0x4(%ecx),%esp 20: ret Young W. Lim Link 2. Object Files Wed 22 / 33

23 main assembly code analysis (1) 16-byte alignment 0: lea 0x4(%esp),%ecx %ecx= %esp+4 : %ecx-4=%esp %ecx = the initial %esp + 4 (%ecx) = normally, the first argument of a function 4: and $0xfffffff0,%esp & 0xFFFFFFF0 16-byte alignment of %esp 7: pushl -0x4(%ecx) push [%ecx-4] (%esp -= 4) push [init_%esp] : content of init_%esp push once more the return address previously stored at the unaligned initial %esp now, store it again at the 16-byte aligned new %esp Young W. Lim Link 2. Object Files Wed 23 / 33

24 main assembly code analysis (2) Function Prologue + a: push %ebp - push %ebp...(%esp -= 4) - push init_%ebp : address init_%ebp + b: mov %esp,%ebp - %ebp= %esp... - new_%ebp = %esp (aligned %esp) + d: push %ecx - push %ecx...(%esp -= 4) - push init_%esp+4 : address init_%esp+4 + e: sub $0x4,%esp - alloc local var s...(%esp -=4) - enlarge %esp by 4 Young W. Lim Link 2. Object Files Wed 24 / 33

25 main assembly code analysis (3) Function Epilogue + 11: call 12 <main+0x12> + 16: add $0x4,%esp dealloc (4) (%esp +=4 + 19: xor %eax,%eax %eax= 0 ;; return 0; + 1b: pop %ecx dealloc (16=12+4) (%esp +=16) + 1c: pop %ebp + 1d: lea -0x4(%ecx),%esp %esp= %ecx : ret Young W. Lim Link 2. Object Files Wed 25 / 33

26 swap source and assembly codes // swap.c extern int buf[]; int *p0 = &buf[0]; int *p1; void swap() { int tmp; p1 = &buf[1]; tmp = *p0; *p0 = *p1; *p1 = tmp; <swap>: 0: mov 0x0,%eax 5: mov 0x4,%ecx b: movl $0x4,0x0 12: 15: mov (%eax),%edx 17: mov %ecx,(%eax) 19: mov %edx,0x4 1f: ret } Young W. Lim Link 2. Object Files Wed 26 / 33

27 relocatable objdump -d main.o main.o: formato del fichero elf32-i386 Desensamblado de la sección.text.startup: <main>: 0: 8d 4c lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 51 push %ecx e: 83 ec 04 sub $0x4,%esp 11: e8 fc ff ff ff call 12 <main+0x12> 16: 83 c4 04 add $0x4,%esp 19: 31 c0 xor %eax,%eax 1b: 59 pop %ecx 1c: 5d pop %ebp 1d: 8d 61 fc lea -0x4(%ecx),%esp 20: c3 ret Young W. Lim Link 2. Object Files Wed 27 / 33

28 relocatable objdump -d swap.o swap.o: formato del fichero elf32-i386 Desensamblado de la sección.text: <swap>: 0: a mov 0x0,%eax 5: 8b 0d mov 0x4,%ecx b: c movl $0x4,0x0 12: : 8b 10 mov (%eax),%edx 17: mov %ecx,(%eax) 19: mov %edx,0x4 1f: c3 ret Young W. Lim Link 2. Object Files Wed 28 / 33

29 executable objdump -d p (disassemble) - main e0 <main>: 80482e0: 8d 4c lea 0x4(%esp),%ecx 80482e4: 83 e4 f0 and $0xfffffff0,%esp 80482e7: ff 71 fc pushl -0x4(%ecx) 80482ea: 55 push %ebp 80482eb: 89 e5 mov %esp,%ebp 80482ed: 51 push %ecx 80482ee: 83 ec 04 sub $0x4,%esp 80482f1: e8 0a call <swap> 80482f6: 83 c4 04 add $0x4,%esp 80482f9: 31 c0 xor %eax,%eax 80482fb: 59 pop %ecx 80482fc: 5d pop %ebp 80482fd: 8d 61 fc lea -0x4(%ecx),%esp : c3 ret Young W. Lim Link 2. Object Files Wed 29 / 33

30 executable objdump -d p (disassemble) - swap <swap>: : a1 20 a mov 0x804a020,%eax : 8b 0d 1c a mov 0x804a01c,%ecx b: c a c movl $0x804a01c,0x804a : a : 8b 10 mov (%eax),%edx : mov %ecx,(%eax) : c a mov %edx,0x804a01c f: c3 ret Young W. Lim Link 2. Object Files Wed 30 / 33

31 executable objdump -d p (disassemble) - section summary./p: formato del fichero elf32-i386 Desensamblado de la sección.init: c <_init>: Desensamblado de la sección.plt: b0 < libc_start_main@plt-0x10>: c0 < libc_start_main@plt>: Desensamblado de la sección.plt.got: d0 <.plt.got>: Desensamblado de la sección.text: e0 <main>: <_start>: < x86.get_pc_thunk.bx>: <deregister_tm_clones>: <register_tm_clones>: b0 < do_global_dtors_aux>: d0 <frame_dummy>: <swap>: < libc_csu_init>: < libc_csu_fini>: Desensamblado de la sección.fini: <_fini>: Young W. Lim Link 2. Object Files Wed 31 / 33

32 relocatable and executable main s <main>: 0: lea 0x4(%esp),%ecx 4: and $0xfffffff0,%esp 7: pushl -0x4(%ecx) a: push %ebp b: mov %esp,%ebp d: push %ecx e: sub $0x4,%esp 11: call 12 <main+0x12> 16: add $0x4,%esp 19: xor %eax,%eax 1b: pop %ecx 1c: pop %ebp 1d: lea -0x4(%ecx),%esp 20: ret e0 <main>: 80482e0: lea 0x4(%esp),%ecx 80482e4: and $0xfffffff0,%esp 80482e7: pushl -0x4(%ecx) 80482ea: push %ebp 80482eb: mov %esp,%ebp 80482ed: push %ecx 80482ee: sub $0x4,%esp 80482f1: call <swap> 80482f6: add $0x4,%esp 80482f9: xor %eax,%eax 80482fb: pop %ecx 80482fc: pop %ebp 80482fd: lea -0x4(%ecx),%esp : ret Young W. Lim Link 2. Object Files Wed 32 / 33

33 relocatable and executable swap s <swap>: 0: mov 0x0,%eax 5: mov 0x4,%ecx b: movl $0x4,0x0 12: 15: mov (%eax),%edx 17: mov %ecx,(%eax) 19: mov %edx,0x4 1f: ret <swap>: : mov 0x804a020,%eax : mov 0x804a01c,%ecx b: movl $0x804a01c,0x804a : : mov (%eax),%edx : mov %ecx,(%eax) : mov %edx,0x804a01c f: ret Young W. Lim Link 2. Object Files Wed 33 / 33

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 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

Link 4. Relocation. Young W. Lim Thr. Young W. Lim Link 4. Relocation Thr 1 / 26

Link 4. Relocation. Young W. Lim Thr. Young W. Lim Link 4. Relocation Thr 1 / 26 Link 4. Relocation Young W. Lim 2017-09-14 Thr Young W. Lim Link 4. Relocation 2017-09-14 Thr 1 / 26 Outline 1 Linking - 4. Relocation Based on Relocation Relocation Entries Relocating Symbol Reference

More information

Link 4. Relocation. Young W. Lim Sat. Young W. Lim Link 4. Relocation Sat 1 / 33

Link 4. Relocation. Young W. Lim Sat. Young W. Lim Link 4. Relocation Sat 1 / 33 Link 4. Relocation Young W. Lim 2017-09-16 Sat Young W. Lim Link 4. Relocation 2017-09-16 Sat 1 / 33 Outline 1 Linking - 4. Relocation Based on Relocation Relocation Entries Relocating Symbol Reference

More information

Link 4. Relocation. Young W. Lim Mon. Young W. Lim Link 4. Relocation Mon 1 / 35

Link 4. Relocation. Young W. Lim Mon. Young W. Lim Link 4. Relocation Mon 1 / 35 Link 4. Relocation Young W. Lim 2017-09-25 Mon Young W. Lim Link 4. Relocation 2017-09-25 Mon 1 / 35 Outline 1 Linking - 4. Relocation Based on Relocation Relocation Entries Relocating Symbol Reference

More information

Link 4. Relocation. Young W. Lim Tue. Young W. Lim Link 4. Relocation Tue 1 / 38

Link 4. Relocation. Young W. Lim Tue. Young W. Lim Link 4. Relocation Tue 1 / 38 Link 4. Relocation Young W. Lim 2017-09-26 Tue Young W. Lim Link 4. Relocation 2017-09-26 Tue 1 / 38 Outline 1 Linking - 4. Relocation Based on Relocation Relocation Entries Relocation Algorithm Reloation

More information

Link 4. Relocation. Young W. Lim Thr. Young W. Lim Link 4. Relocation Thr 1 / 48

Link 4. Relocation. Young W. Lim Thr. Young W. Lim Link 4. Relocation Thr 1 / 48 Link 4. Relocation Young W. Lim 2017-09-28 Thr Young W. Lim Link 4. Relocation 2017-09-28 Thr 1 / 48 Outline 1 Linking - 4. Relocation Based on Relocation Relocation Entries Relocation Algorithm Reloation

More information

Procedure Calls. Young W. Lim Sat. Young W. Lim Procedure Calls Sat 1 / 27

Procedure Calls. Young W. Lim Sat. Young W. Lim Procedure Calls Sat 1 / 27 Procedure Calls Young W. Lim 2016-11-05 Sat Young W. Lim Procedure Calls 2016-11-05 Sat 1 / 27 Outline 1 Introduction References Stack Background Transferring Control Register Usage Conventions Procedure

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

Procedure Calls. Young W. Lim Mon. Young W. Lim Procedure Calls Mon 1 / 29

Procedure Calls. Young W. Lim Mon. Young W. Lim Procedure Calls Mon 1 / 29 Procedure Calls Young W. Lim 2017-08-21 Mon Young W. Lim Procedure Calls 2017-08-21 Mon 1 / 29 Outline 1 Introduction Based on Stack Background Transferring Control Register Usage Conventions Procedure

More information

Stack Tutorial. Young W. Lim Sat. Young W. Lim Stack Tutorial Sat 1 / 15

Stack Tutorial. Young W. Lim Sat. Young W. Lim Stack Tutorial Sat 1 / 15 Stack Tutorial Young W. Lim 2016-10-15 Sat Young W. Lim Stack Tutorial 2016-10-15 Sat 1 / 15 Outline 1 Introduction References Stack Background Transferring Control Young W. Lim Stack Tutorial 2016-10-15

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

Access. Young W. Lim Sat. Young W. Lim Access Sat 1 / 19

Access. Young W. Lim Sat. Young W. Lim Access Sat 1 / 19 Access Young W. Lim 2017-06-10 Sat Young W. Lim Access 2017-06-10 Sat 1 / 19 Outline 1 Introduction References IA32 Operand Forms Data Movement Instructions Data Movement Examples Young W. Lim Access 2017-06-10

More information

Access. Young W. Lim Fri. Young W. Lim Access Fri 1 / 18

Access. Young W. Lim Fri. Young W. Lim Access Fri 1 / 18 Access Young W. Lim 2017-01-27 Fri Young W. Lim Access 2017-01-27 Fri 1 / 18 Outline 1 Introduction References IA32 Operand Forms Data Movement Instructions Young W. Lim Access 2017-01-27 Fri 2 / 18 Based

More information

Link 7. Static Linking

Link 7. Static Linking Link 7. Static Linking Young W. Lim 2018-12-21 Fri Young W. Lim Link 7. Static Linking 2018-12-21 Fri 1 / 41 Outline 1 Linking - 7. Static Linking Based on Static Library Examples Linking with Static Libraries

More information

Arrays. Young W. Lim Wed. Young W. Lim Arrays Wed 1 / 19

Arrays. Young W. Lim Wed. Young W. Lim Arrays Wed 1 / 19 Arrays Young W. Lim 2017-02-08 Wed Young W. Lim Arrays 2017-02-08 Wed 1 / 19 Outline 1 Introduction References Array Background Young W. Lim Arrays 2017-02-08 Wed 2 / 19 Based on "Self-service Linux: Mastering

More information

Arrays. Young W. Lim Mon. Young W. Lim Arrays Mon 1 / 17

Arrays. Young W. Lim Mon. Young W. Lim Arrays Mon 1 / 17 Arrays Young W. Lim 2017-02-06 Mon Young W. Lim Arrays 2017-02-06 Mon 1 / 17 Outline 1 Introduction References Array Background Young W. Lim Arrays 2017-02-06 Mon 2 / 17 Based on "Self-service Linux: Mastering

More information

Binghamton University. CS-220 Spring Loading Code. Computer Systems Chapter 7.5, 7.8, 7.9

Binghamton University. CS-220 Spring Loading Code. Computer Systems Chapter 7.5, 7.8, 7.9 Loading Code Computer Systems Chapter 7.5, 7.8, 7.9 gcc g o ttt ttt.c ttt.c ttt gcc gcc g o ttt ttt.c ttt.c gcc ttt Pre-Processor Linker Compiler Assembler ttt.s ttt.o What is in a binary executable file?

More information

Stack Debugging. Young W. Lim Sat. Young W. Lim Stack Debugging Sat 1 / 40

Stack Debugging. Young W. Lim Sat. Young W. Lim Stack Debugging Sat 1 / 40 Stack Debugging Young W. Lim 2017-07-22 Sat Young W. Lim Stack Debugging 2017-07-22 Sat 1 / 40 Outline 1 Introduction References Compiling to IA32 Assembly Checking /proc//maps file Checking Stack

More information

Intro x86 Part 3: Linux Tools & Analysis

Intro x86 Part 3: Linux Tools & Analysis Intro x86 Part 3: Linux Tools & Analysis Xeno Kovah 2009/2010 xkovah at gmail Approved for Public Release: 10-3348. Distribution Unlimited All materials is licensed under a Creative Commons Share Alike

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

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

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

CMSC 313 Lecture 12. Project 3 Questions. How C functions pass parameters. UMBC, CMSC313, Richard Chang

CMSC 313 Lecture 12. Project 3 Questions. How C functions pass parameters. UMBC, CMSC313, Richard Chang Project 3 Questions CMSC 313 Lecture 12 How C functions pass parameters UMBC, CMSC313, Richard Chang Last Time Stack Instructions: PUSH, POP PUSH adds an item to the top of the stack POP

More information

Link 7. Dynamic Linking

Link 7. Dynamic Linking Link 7. Dynamic Linking Young W. Lim 2018-10-05 Fri Young W. Lim Link 7. Dynamic Linking 2018-10-05 Fri 1 / 26 Outline 1 Linking - 7. Dynamic Linking Based on Dynamic Shared Library Examples Young W. Lim

More information

Link 8.A Dynamic Linking

Link 8.A Dynamic Linking Link 8.A Dynamic Linking Young W. Lim 2019-01-04 Fri Young W. Lim Link 8.A Dynamic Linking 2019-01-04 Fri 1 / 42 Outline 1 Linking - 8.A Dynamic Linking Based on Dynamic linking with a shared library example

More information

CMSC 313 Lecture 12 [draft] How C functions pass parameters

CMSC 313 Lecture 12 [draft] How C functions pass parameters CMSC 313 Lecture 12 [draft] How C functions pass parameters UMBC, CMSC313, Richard Chang Last Time Stack Instructions: PUSH, POP PUSH adds an item to the top of the stack POP removes an

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

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

Link 7.A Static Linking

Link 7.A Static Linking Link 7.A Static Linking Young W. Lim 2019-01-04 Fri Young W. Lim Link 7.A Static Linking 2019-01-04 Fri 1 / 27 Outline 1 Linking - 7.A Static Linking Based on Static Library Examples Linking with Static

More information

Link Edits and Relocatable Code

Link Edits and Relocatable Code Link Edits and Relocatable Code Computer Systems Chapter 7.4-7.7 gcc g o ttt ttt.c ttt.c gcc ttt Pre-Processor Linker Compiler Assembler ttt.s ttt.o gcc g o ttt ttt.c main.c gcc cmd util.c Pre-Processor

More information

CS , Fall 2001 Exam 1

CS , Fall 2001 Exam 1 Andrew login ID: Full Name: CS 15-213, Fall 2001 Exam 1 October 9, 2001 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front. Write

More information

CSC 2400: Computing Systems. X86 Assembly: Function Calls

CSC 2400: Computing Systems. X86 Assembly: Function Calls CSC 24: Computing Systems X86 Assembly: Function Calls 1 Lecture Goals Challenges of supporting functions Providing information for the called function Function arguments and local variables Allowing the

More information

CSC 405 Computer Security Stack Canaries & ASLR

CSC 405 Computer Security Stack Canaries & ASLR CSC 405 Computer Security Stack Canaries & ASLR Alexandros Kapravelos akaprav@ncsu.edu How can we prevent a buffer overflow? Check bounds Programmer Language Stack canaries [...more ] Buffer overflow defenses

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

Turning C into Object Code Code in files p1.c p2.c Compile with command: gcc -O p1.c p2.c -o p Use optimizations (-O) Put resulting binary in file p

Turning C into Object Code Code in files p1.c p2.c Compile with command: gcc -O p1.c p2.c -o p Use optimizations (-O) Put resulting binary in file p Turning C into Object Code Code in files p1.c p2.c Compile with command: gcc -O p1.c p2.c -o p Use optimizations (-O) Put resulting binary in file p text C program (p1.c p2.c) Compiler (gcc -S) text Asm

More information

CSC 405 Computer Security Reverse Engineering Part 1

CSC 405 Computer Security Reverse Engineering Part 1 CSC 405 Computer Security Reverse Engineering Part 1 Alexandros Kapravelos akaprav@ncsu.edu Introduction Reverse engineering process of analyzing a system understand its structure and functionality used

More information

Stack Debugging. Young W. Lim Thr. Young W. Lim Stack Debugging Thr 1 / 12

Stack Debugging. Young W. Lim Thr. Young W. Lim Stack Debugging Thr 1 / 12 Stack Debugging Young W. Lim 2017-07-13 Thr Young W. Lim Stack Debugging 2017-07-13 Thr 1 / 12 Outline 1 Introduction References Compiling to IA32 Assembly Checking /proc//maps file Young W. Lim Stack

More information

Introduction to Computer Systems , fall th Lecture, Sep. 28 th

Introduction to Computer Systems , fall th Lecture, Sep. 28 th Introduction to Computer Systems 15 213, fall 2009 9 th Lecture, Sep. 28 th Instructors: Majd Sakr and Khaled Harras Last Time: Structures struct rec { int i; int a[3]; int *p; }; Memory Layout i a p 0

More information

CS 550 Operating Systems Spring Process I

CS 550 Operating Systems Spring Process I CS 550 Operating Systems Spring 2018 Process I 1 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

More information

Homework. In-line Assembly Code Machine Language Program Efficiency Tricks Reading PAL, pp 3-6, Practice Exam 1

Homework. In-line Assembly Code Machine Language Program Efficiency Tricks Reading PAL, pp 3-6, Practice Exam 1 Homework In-line Assembly Code Machine Language Program Efficiency Tricks Reading PAL, pp 3-6, 361-367 Practice Exam 1 1 In-line Assembly Code The gcc compiler allows you to put assembly instructions in-line

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

CS , Fall 2004 Exam 1

CS , Fall 2004 Exam 1 Andrew login ID: Full Name: CS 15-213, Fall 2004 Exam 1 Tuesday October 12, 2004 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front.

More information

Buffer Overflow Attack

Buffer Overflow Attack Buffer Overflow Attack What every applicant for the hacker should know about the foundation of buffer overflow attacks By (Dalgona@wowhacker.org) Email: zinwon@gmail.com 2005 9 5 Abstract Buffer overflow.

More information

CS , Spring 2004 Exam 1

CS , Spring 2004 Exam 1 Andrew login ID: Full Name: CS 15-213, Spring 2004 Exam 1 February 26, 2004 Instructions: Make sure that your exam is not missing any sheets (there should be 15), then write your full name and Andrew login

More information

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING PREVIEW SLIDES 16, SPRING 2013

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING PREVIEW SLIDES 16, SPRING 2013 CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING PREVIEW SLIDES 16, SPRING 2013 CONST POINTERS CONST POINTERS 4 ways to declare pointers in combination with const:!! int *ptr! const int *ptr!

More information

Overview of Compiler. A. Introduction

Overview of Compiler. A. Introduction CMPSC 470 Lecture 01 Topics: Overview of compiler Compiling process Structure of compiler Programming language basics Overview of Compiler A. Introduction What is compiler? What is interpreter? A very

More information

CSC 591 Systems Attacks and Defenses Reverse Engineering Part 1

CSC 591 Systems Attacks and Defenses Reverse Engineering Part 1 CSC 591 Systems Attacks and Defenses Reverse Engineering Part 1 Alexandros Kapravelos akaprav@ncsu.edu Reverse engineering Introduction process of analyzing a system understand its structure and functionality

More information

AS08-C++ and Assembly Calling and Returning. CS220 Logic Design AS08-C++ and Assembly. AS08-C++ and Assembly Calling Conventions

AS08-C++ and Assembly Calling and Returning. CS220 Logic Design AS08-C++ and Assembly. AS08-C++ and Assembly Calling Conventions CS220 Logic Design Outline Calling Conventions Multi-module Programs 1 Calling and Returning We have already seen how the call instruction is used to execute a subprogram. call pushes the address of the

More information

Full Name: CISC 360, Fall 2008 Example of Exam

Full Name: CISC 360, Fall 2008 Example of Exam Full Name: CISC 360, Fall 2008 Example of Exam Page 1 of 0 Problem 1. (12 points): Consider the following 8-bit floating point representation based on the IEEE floating point format: There is a sign bit

More information

Buffer Overflow Attacks

Buffer Overflow Attacks CS- Spring Buffer Overflow Attacks Computer Systems..-, CS- Spring Hacking Roots in phone phreaking White Hat vs Gray Hat vs Black Hat Over % of Modern Software Development is Black Hat! Tip the balance:

More information

GAS Tutorial - 4. Sections & Relocation

GAS Tutorial - 4. Sections & Relocation GAS Tutorial - 4. Sections & Relocation Young W. Lim 2016-03-01 Tue Young W. Lim GAS Tutorial - 4. Sections & Relocation 2016-03-01 Tue 1 / 22 Outline 1 Sections and Relocation Young W. Lim GAS Tutorial

More information

Assembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction

Assembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction Assembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction E I P CPU isters Condition Codes Addresses Data Instructions Memory Object Code Program Data OS Data Topics Assembly Programmer

More information

CS 2505 Computer Organization I Test 2. Do not start the test until instructed to do so! printed

CS 2505 Computer Organization I Test 2. Do not start the test until instructed to do so! printed Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other electronic devices

More information

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

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

GDB Tutorial. Young W. Lim Thr. Young W. Lim GDB Tutorial Thr 1 / 24

GDB Tutorial. Young W. Lim Thr. Young W. Lim GDB Tutorial Thr 1 / 24 GDB Tutorial Young W. Lim 2016-09-29 Thr Young W. Lim GDB Tutorial 2016-09-29 Thr 1 / 24 Outline 1 Introduction Young W. Lim GDB Tutorial 2016-09-29 Thr 2 / 24 Based on "Self-service Linux: Mastering the

More information

UW CSE 351, Winter 2013 Midterm Exam

UW CSE 351, Winter 2013 Midterm Exam Full Name: Student ID: UW CSE 351, Winter 2013 Midterm Exam February 15, 2013 Instructions: Make sure that your exam is not missing any of the 9 pages, then write your full name and UW student ID on the

More information

Day06 A. Young W. Lim Mon. Young W. Lim Day06 A Mon 1 / 16

Day06 A. Young W. Lim Mon. Young W. Lim Day06 A Mon 1 / 16 Day06 A Young W. Lim 2017-09-18 Mon Young W. Lim Day06 A 2017-09-18 Mon 1 / 16 Outline 1 Based on 2 Introduction C Program Control Young W. Lim Day06 A 2017-09-18 Mon 2 / 16 Based on "C How to Program",

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

CS , Spring 2002 Exam 2

CS , Spring 2002 Exam 2 Full Name: CS 15-213, Spring 2002 Exam 2 March 28, 2002 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front. Write your answers

More information

Machine Programming 1: Introduction

Machine Programming 1: Introduction Machine Programming 1: Introduction CS61, Lecture 3 Prof. Stephen Chong September 8, 2011 Announcements (1/2) Assignment 1 due Tuesday Please fill in survey by 5pm today! Assignment 2 will be released

More information

GDB Tutorial. Young W. Lim Fri. Young W. Lim GDB Tutorial Fri 1 / 24

GDB Tutorial. Young W. Lim Fri. Young W. Lim GDB Tutorial Fri 1 / 24 GDB Tutorial Young W. Lim 2016-02-19 Fri Young W. Lim GDB Tutorial 2016-02-19 Fri 1 / 24 Outline 1 Introduction Young W. Lim GDB Tutorial 2016-02-19 Fri 2 / 24 Based on Self-service Linux: Mastering the

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

CSC 2400: Computing Systems. X86 Assembly: Function Calls"

CSC 2400: Computing Systems. X86 Assembly: Function Calls CSC 24: Computing Systems X86 Assembly: Function Calls" 1 Lecture Goals! Challenges of supporting functions" Providing information for the called function" Function arguments and local variables" Allowing

More information

Labeling Library Functions in Stripped Binaries

Labeling Library Functions in Stripped Binaries Labeling Library Functions in Stripped Binaries Emily R. Jacobson, Nathan Rosenblum, and Barton P. Miller Computer Sciences Department University of Wisconsin - Madison PASTE 2011 Szeged, Hungary September

More information

Sungkyunkwan University

Sungkyunkwan University November, 1988 Internet Worm attacks thousands of Internet hosts. How did it happen? November, 1988 Internet Worm attacks thousands of Internet hosts. How did it happen? July, 1999 Microsoft launches MSN

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

GDB Tutorial. Young W. Lim Tue. Young W. Lim GDB Tutorial Tue 1 / 32

GDB Tutorial. Young W. Lim Tue. Young W. Lim GDB Tutorial Tue 1 / 32 GDB Tutorial Young W. Lim 2017-02-14 Tue Young W. Lim GDB Tutorial 2017-02-14 Tue 1 / 32 Outline 1 Introduction Young W. Lim GDB Tutorial 2017-02-14 Tue 2 / 32 Based on "Self-service Linux: Mastering the

More information

238P: Operating Systems. Lecture 4: Linking and Loading (Basic architecture of a program) Anton Burtsev October, 2018

238P: Operating Systems. Lecture 4: Linking and Loading (Basic architecture of a program) Anton Burtsev October, 2018 238P: Operating Systems Lecture 4: Linking and Loading (Basic architecture of a program) Anton Burtsev October, 2018 What is a program? What parts do we need to run code? Parts needed to run a program

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 , Fall 2002 Exam 1

CS , Fall 2002 Exam 1 Andrew login ID: Full Name: CS 15-213, Fall 2002 Exam 1 October 8, 2002 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front. Write

More information

THEORY OF COMPILATION

THEORY OF COMPILATION Lecture 10 Activation Records THEORY OF COMPILATION EranYahav www.cs.technion.ac.il/~yahave/tocs2011/compilers-lec10.pptx Reference: Dragon 7.1,7.2. MCD 6.3,6.4.2 1 You are here Compiler txt Source Lexical

More information

Overview REWARDS TIE HOWARD Summary CS 6V Data Structure Reverse Engineering. Zhiqiang Lin

Overview REWARDS TIE HOWARD Summary CS 6V Data Structure Reverse Engineering. Zhiqiang Lin CS 6V81-05 Data Structure Reverse Engineering Zhiqiang Lin Department of Computer Science The University of Texas at Dallas September 2 nd, 2011 Outline 1 Overview 2 REWARDS 3 TIE 4 HOWARD 5 Summary Outline

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

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

Lecture 2 Assembly Language

Lecture 2 Assembly Language Lecture 2 Assembly Language Computer and Network Security 9th of October 2017 Computer Science and Engineering Department CSE Dep, ACS, UPB Lecture 2, Assembly Language 1/37 Recap: Explorations Tools assembly

More information

Machine-Level Programming I: Introduction Jan. 30, 2001

Machine-Level Programming I: Introduction Jan. 30, 2001 15-213 Machine-Level Programming I: Introduction Jan. 30, 2001 Topics Assembly Programmer s Execution Model Accessing Information Registers Memory Arithmetic operations IA32 Processors Totally Dominate

More information

CSC 591 Systems Attacks and Defenses Return-into-libc & ROP

CSC 591 Systems Attacks and Defenses Return-into-libc & ROP CSC 591 Systems Attacks and Defenses Return-into-libc & ROP Alexandros Kapravelos akaprav@ncsu.edu NOEXEC (W^X) 0xFFFFFF Stack Heap BSS Data 0x000000 Code RW RX Deployment Linux (via PaX patches) OpenBSD

More information

CS241 Computer Organization Spring Buffer Overflow

CS241 Computer Organization Spring Buffer Overflow CS241 Computer Organization Spring 2015 Buffer Overflow 4-02 2015 Outline! Linking & Loading, continued! Buffer Overflow Read: CSAPP2: section 3.12: out-of-bounds memory references & buffer overflow K&R:

More information

administrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions?

administrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions? administrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions? exam on Wednesday today s material not on the exam 1 Assembly Assembly is programming

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

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

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

CS241 Computer Organization Spring 2015 IA

CS241 Computer Organization Spring 2015 IA CS241 Computer Organization Spring 2015 IA-32 2-10 2015 Outline! Review HW#3 and Quiz#1! More on Assembly (IA32) move instruction (mov) memory address computation arithmetic & logic instructions (add,

More information

1 /* file cpuid2.s */ 4.asciz "The processor Vendor ID is %s \n" 5.section.bss. 6.lcomm buffer, section.text. 8.globl _start.

1 /* file cpuid2.s */ 4.asciz The processor Vendor ID is %s \n 5.section.bss. 6.lcomm buffer, section.text. 8.globl _start. 1 /* file cpuid2.s */ 2.section.data 3 output: 4.asciz "The processor Vendor ID is %s \n" 5.section.bss 6.lcomm buffer, 12 7.section.text 8.globl _start 9 _start: 10 movl $0, %eax 11 cpuid 12 movl $buffer,

More information

Control. Young W. Lim Mon. Young W. Lim Control Mon 1 / 16

Control. Young W. Lim Mon. Young W. Lim Control Mon 1 / 16 Control Young W. Lim 2016-11-21 Mon Young W. Lim Control 2016-11-21 Mon 1 / 16 Outline 1 Introduction References Condition Code Accessing the Conditon Codes Jump Instructions Translating Conditional Branches

More information

Advanced Buffer Overflow

Advanced Buffer Overflow Pattern Recognition and Applications Lab Advanced Buffer Overflow Ing. Davide Maiorca, Ph.D. davide.maiorca@diee.unica.it Computer Security A.Y. 2016/2017 Department of Electrical and Electronic Engineering

More information

A SimplisHc Program TranslaHon Scheme. TranslaHng the Example Program. Example C Program. Why Linkers? - Modularity. Linking

A SimplisHc Program TranslaHon Scheme. TranslaHng the Example Program. Example C Program. Why Linkers? - Modularity. Linking A SimplisHc Program TranslaHon Scheme Linking ASCII (Text) source file The American Standard Code for InformaHon Interchange (ASCII) CSCI 221: Machine Architecture and OrganizaHon Pen- Chung Yew Department

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

Systems I. Machine-Level Programming I: Introduction

Systems I. Machine-Level Programming I: Introduction Systems I Machine-Level Programming I: Introduction Topics Assembly Programmerʼs Execution Model Accessing Information Registers IA32 Processors Totally Dominate General Purpose CPU Market Evolutionary

More information

CPEG421/621 Tutorial

CPEG421/621 Tutorial CPEG421/621 Tutorial Compiler data representation system call interface calling convention Assembler object file format object code model Linker program initialization exception handling relocation model

More information

Practical Malware Analysis

Practical Malware Analysis Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the

More information

143A: Principles of Operating Systems. Lecture 4: Linking and Loading (Basic architecture of a program) Anton Burtsev October, 2018

143A: Principles of Operating Systems. Lecture 4: Linking and Loading (Basic architecture of a program) Anton Burtsev October, 2018 143A: Principles of Operating Systems Lecture 4: Linking and Loading (Basic architecture of a program) Anton Burtsev October, 2018 What is a program? What parts do we need to run code? Parts needed to

More information

IA-32 Architecture. CS 4440/7440 Malware Analysis and Defense

IA-32 Architecture. CS 4440/7440 Malware Analysis and Defense IA-32 Architecture CS 4440/7440 Malware Analysis and Defense Intel x86 Architecture } Security professionals constantly analyze assembly language code } Many exploits are written in assembly } Source code

More information

CISC 360. Machine-Level Programming I: Introduction Sept. 18, 2008

CISC 360. Machine-Level Programming I: Introduction Sept. 18, 2008 CISC 360 Machine-Level Programming I: Introduction Sept. 18, 2008 Topics Assembly Programmerʼs Execution Model Accessing Information Registers Memory Arithmetic operations IA32 Processors Totally Dominate

More information

Introduction Presentation A

Introduction Presentation A CSE 2421/5042: Systems I Low-Level Programming and Computer Organization Introduction Presentation A Read carefully: Bryant Chapter 1 Study: Reek Chapter 2 Skim: Reek Chapter 1 08/22/2018 Gojko Babić Some

More information

CF Carry Flag SF Sign Flag ZF Zero Flag OF Overflow Flag. ! CF set if carry out from most significant bit. "Used to detect unsigned overflow

CF Carry Flag SF Sign Flag ZF Zero Flag OF Overflow Flag. ! CF set if carry out from most significant bit. Used to detect unsigned overflow Lecture 4B Machine-Level Programming II: Control Flow Topics! Condition Codes " Setting " Testing! Control Flow " If-then-else " Varieties of Loops " Switch Statements Condition Codes Single Bit Registers

More information

Process Layout, Function Calls, and the Heap

Process Layout, Function Calls, and the Heap Process Layout, Function Calls, and the Heap CS 6 Spring 20 Prof. Vern Paxson TAs: Devdatta Akhawe, Mobin Javed, Matthias Vallentin January 9, 20 / 5 2 / 5 Outline Process Layout Function Calls The Heap

More information

Condition Codes. Lecture 4B Machine-Level Programming II: Control Flow. Setting Condition Codes (cont.) Setting Condition Codes (cont.

Condition Codes. Lecture 4B Machine-Level Programming II: Control Flow. Setting Condition Codes (cont.) Setting Condition Codes (cont. Lecture 4B Machine-Level Programming II: Control Flow Topics Condition Codes Setting Testing Control Flow If-then-else Varieties of Loops Switch Statements Condition Codes Single Bit Registers CF Carry

More information