CS 240 Lab 7

Learning Goals & Reflection

CS 240 Lab 7

Learning Goals

Core Goals

Students can:

  1. Use gcc to compile code.
    1. Look up the meaning of gcc flags.
    2. Use gcc to compile C code into assembly code.
    3. Use gcc to compile C code into an executable binary.
    4. Explain how the -Wall, -std=c99, -S, and -o flags for gcc change its behavior.
  2. Use objdump and/or gdb to disassemble an executable file.
    1. Explain how to use objdump on a binary file.
    2. Explain what the three columns of output from objdump are.
    3. Explain how to use the disas command in gdb to disassemble a function.
    4. Explain What the + numbers in the disas output mean.
  3. Identify and explain core x86 assembly instructions.
    1. Look up the reference for an unfamiliar assembly instruction and understand what it is saying.
    2. Explain what the mov family of instructions does.
    3. Explain what the j* family of instructions does.
    4. Explain what the cmp/test family of instructions does.
  4. Explain the relationship between assembly code and C code.
    1. Identify function calls in assembly code.
    2. Explain how comparison instructions link with conditional jump instructions in assembly code.
    3. Identify how many parameters a function uses by looking at its assembly code, for functions with up to 6 parameters.
    4. Identify which line(s) of code in an assembly program set return value(s) for a function.
    5. Identify conditionals and loops within assembly code.
    6. Identify which registers are used as pointers in assembly code.
  5. Explain the usage of key x86 registers.
    1. Explain what the %rax register is used for in x86 assembly code.
    2. Explain what the %rdi, %rsi, %rdx, %rcx, %r8, and %r9 registers are used for when calling functions in x86 assembly code.
  6. Reverse engineer an executable file to figure out what the code is doing.
    1. Given a binary file, disassemble it to read the assembly instructions.
    2. Given assembly code for a function which compares input against a specific string, use gdb to figure out what that string is, and provide input to manipulate the comparison.

Stretch goals

  1. Identify and explain core x86 assembly instructions.
    1. Explain what the lea instruction does.
    2. Explain what the push and pop instructions do.
  2. Explain the relationship between assembly code and C code.
    1. Explain how the lea instruction is used in relation to the & operator and also explain its use for general arithmetic.
  3. Explain the usage of key x86 registers.
    1. Explain what the %rsp register is used for in x86 assembly code.
  4. Reverse engineer an executable file to figure out what the code is doing.
    1. Given assembly code that uses a loop to check relationships among a sequence of numbers, figure out exactly what the loop checks for, and provide a sequence of numbers that will pass the checks.

Extra goals

  1. Explain the usage of key x86 registers.
    1. Explain what the %rbp register is used for in x86 assembly code.

Reflection

Fill out the CS 240 Lab 7 Reflection form to complete today’s lab reflection.