Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Lab2 BombLab

The original tar file is bomblab.tar and the writeup is bomblab.pdf. My solution is in datalab-solution.

Before starting

The video from recitation 04 is very helpful. You can start working on this lab after watching Machine Prog: Control, but may want to finish the lecture of Machine Prog: Data to finish the entire lab.

Notes of Files

  1. disassembled.sis generate by: objdump -d bomb > disassembled.s.
  2. symbolTable is generated by: objdump -t bomb > symbolTable.
  3. printableStrings.txt is generated by: strings bomb > printableStrings.txt.

I mainly rely on disassembled.s and gdb when solving this lab. disassembled.s includes the translation of assembly code as well as other notes. I find x, print, disas, step, si, next, ni instructions very useful in gdb.
x command: http://visualgdb.com/gdbreference/commands/x
print command: http://visualgdb.com/gdbreference/commands/print

Problem Analysis

  • phase_1
    This problem is relatively easy.
  • phase_2
    This problem is much harder than phase_1 in my opinion. The main complexity come from 2 parts:
    • function read_six_numbers: you need to use a loop and compute address to fill numberes onto stack. Also, you need the knowledge of passing more than 6 arguments to a function.
    • After read_six_numbers, another loop is used to impose certain requirements on the 6 input numbers.
  • phase_3
    If you are aware of the usage of jump table, then this problem is straightforward. Some StackOverflow links are avaiable in the my notes in disassembled.s.
  • phase_4
    The major part of phase_4 is strarightforward, except for fun4. Actually when solving this problem, I did not fully understand what fun4 does. However, I try to input some numbers and see what the result is. It turns out that this also solves the problem. Thus, this is not too hard.
  • phase_5
    This problem is complicated, but not too hard. Again, something like a matching table is used.
  • phase_6
    This problem is the most difficult one in this lab, just as indicated by Randal Bryant.
    The first half uses several loops to ensure certain requirement on the input numbers, which could be confusing and complex. I would say more about my personal experience for tackling this shortly afterwards.
    The second half, again, uses something like a table, at least at first glance. However, you would find it very confusing if you take it like a table. I spent several hours on it and cannot figure it out. Then I consulted this link: http://zpalexander.com/binary-bomb-lab-phase-6/ and realizes that this is something like a linked list! Then everything start to make sense and I solve it the remaining part in one hour.

Gains and techniques

  • Big picture v.s. Details.
    My normal procedure when reading the assembly code is:

    1. translate assembly code to more readable pseudocode;
    2. try to understand the logic of each command in detail.
      Then I find that this might not work well for code that involve complex logic like nested loop. Since there are so many registers involved and as they are not given meaningful name, you quickly get overwhelmed.
      Then I find that, after you are very familar with each command, you should back up and look at the code snippet as a whole. This is likely to give you a better understanding of the general structure of the code, which you cannot achieve by keeping track of each register carefully using paper.
  • Some trials with educated guess can be helpful.
    Try some inputs when you feel clueless. This might give you further information and help you to make more infomative guess.