Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 Object Code.

Slides:



Advertisements
Similar presentations
Practical Malware Analysis
Advertisements

Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
UEE072HM Linking HLL and ALP An example on ARM. Embedded and Real-Time Systems We will mainly look at embedded systems –Systems which have the computer.
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3 J. Levine: Linkers & Loaders
Linking & Loading CS-502 Operating Systems
CS 31003: Compilers ANIRUDDHA GUPTA 11CS10004 G2 CLASS DATE : 24/07/2013.
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Assembly 01. Outline Binary vs. Text Files Compiler vs. Assembler Mnemonic Assembly Process Development Process Debugging Example 1 this analogy will.
Assembly Process. Machine Code Generation Assembling a program entails translating the assembly language into binary machine code This requires more than.
 Procedures (subroutines) allow the programmer to structure programs making them : › easier to understand and debug and › allowing code to be reused.
Linking and Loading Fred Prussack CS 518. L&L: Overview Wake-up Questions Terms and Definitions / General Information LoadingLinking –Static vs. Dynamic.
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3.
Designing a Virtual Machine. Basic Approach Object-oriented design Try to model the hardware. Seek a level of detail that is appropriate for interpretation.
Memory Image of Running Programs Executable file on disk, running program in memory, activation record, C-style and Pascal-style parameter passing.
Chapter 3 Assembly Language: Part 1. Machine language program (in hex notation) from Chapter 2.
Some thoughts: If it is too good to be true, it isn’t. Success is temporary. It is hard work to make it simple. Knowing you did it right is enough reward.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Choice for the rest of the semester New Plan –assembler and machine language –Operating systems Process scheduling Memory management File system Optimization.
Table 1. Software Hierarchy Levels.. Essential Tools An assembler is a program that converts source-code programs into a machine language (object file).
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
Computer Science 210 Computer Organization The Instruction Execution Cycle.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2011.
MIPS coding. SPIM Some links can be found such as:
Practical Session 4. Labels Definition - advanced label: (pseudo) instruction operands ; comment valid characters in labels are: letters, numbers, _,
Lecture-1 Compilation process
The Central Processing Unit (CPU) and the Machine Cycle.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
CMSC 150 PROGRAM EXECUTION CS 150: Wed 1 Feb 2012.
CS412/413 Introduction to Compilers and Translators April 14, 1999 Lecture 29: Linking and loading.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
The Assembly Process Computer Organization and Assembly Language: Module 10.
Linking I Topics Assembly and symbol resolution Static linking Systems I.
Program Translation and Execution I: Linking Sept. 29, 1998 Topics object files linkers class11.ppt Introduction to Computer Systems.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2014.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
1 Computer Architecture & Assembly Language Spring 2001 Dr. Richard Spillman Lecture 10 –Assembly V.
Program Execution in Linux David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
C OMPUTER O RGANIZATION AND D ESIGN The Hardware/Software Interface Chapter 2 Instructions: Language of the Computer.
Lecture 3 Translation.
Instruction Set Architecture
Instruction Set Architectures
Assembly language.
Memory management.
Computer Science 210 Computer Organization
Computer Architecture and Assembly Language
Debugging with gdb gdb is the GNU debugger on our CS machines.
Program Execution in Linux
Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 4 – The Instruction Set Architecture.
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
CALL & Pthread.
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
CSCE Fall 2013 Prof. Jennifer L. Welch.
CSCE 121: Simple Computer Model Spring 2015
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2015.
CNT4704: Analysis of Computer Communication Network Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Fall 2011.
System Calls David Ferry CSCI 3500 – Operating Systems
CSCE Fall 2012 Prof. Jennifer L. Welch.
Program Execution in Linux
10/6: Lecture Topics C Brainteaser More on Procedure Call
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2016.
Program Assembly.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2013.
Exploitation Part 1.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2010.
SPL – PS1 Introduction to C++.
Computer Architecture and System Programming Laboratory
Algoritmos y Programacion
Presentation transcript:

Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 Object Code

Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 Object Code Defined Binary translation of assembler code Format acceptable to the hardware Often also called “binary” or “machine” code

Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 Symbol Table Variable Name LocationOffset arg1base%ebp+4 arg2base%ebp+8 lvar1stack%esp lvar2stack%esp+4 lvar3stack%esp+8 int myfunc(int arg1,char arg2) { int lvar1; char lvar2; int lvar3=1; … }

Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 Object Code consists of List of instructions and Data Each instruction is 1 or more bytes long (depends on instruction) Each instruction starts with an Operation Code (opcode) Opcodes are 0x00 – 0xff 0x0f – “extended” 2 byte op-code Arguments: binary code – Format depends on opcode Registers are numbered Offsets expressed as integers in object Addresses expressed in binary Leave the details to the compiler/dis-assembler Reference to data or functions outside of this file remain unresolved! (place-holders)

Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 Object vs. Assembler Assembler “Man Readable” Labels “Variable Names” Line numbers Comments Object Machine Readable Addresses (or offsets) Addresses [-g exception] [-g exception]

Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 Disassembly Turning object code back into x86 assembler (ASCII) If no debug info is present All local variables expressed as (%esp) All parameter variables expressed as (%ebp) Function calls expressed as absolute address in memory (if loaded) or… Offset from main e.g. call 14 Offset from main to a placeholder for an unresolved reference Function names often kept even without -g

Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 Link Edit (or Link) Joining multiple object files into a single binary executable file Resolving unresolved references Replace place-holders with real values where possible Note: Absolute addresses still unknown Keep track of locations via offsets rather than absolute locations Note: Not all unresolved references may be resolved Statically linked libraries resolved at link edit time Dynamically linked libraries remain unresolved – but checked Linker reports unresolved references that cannot be resolved dynamically Result: Binary executable file (in Windows,.exe. in Unix, no suffix)

Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 myprog.o Making a command myprog.s Assembler myprog.o Linker mycmd objdump staticlib.a myprog.o myprog.s “disassembly”

Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 Running a command Loading the command: Parsing the command line into argc and argv Loading a binary file into memory Loading required dynamically linked libraries into memory Resolving unresolved references to dynamic libraries Replacing offsets with real addresses if required Push argc and argv on stack Executing the command: call main

Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 Instruction Processing Cycle Fetch Instruction Decode Fetch Operands Execute Store Results EIP Increments EIP!