CS31 Weekly Lab: Week 7

Week 7 lab topics:

  1. bomb lab help
  2. tools for examining binary files

Tools for examining executables
A reminder of some of the tools for examining binary files:
  1. strings: dumps all the strings in a binary file
      strings a.out
    
  2. nm (or objdump -t) to list symbol table contents
      nm --format sysv a.out          # dump the symbol table in the a.out file
      objdump -t  a.out               # dump the symbol table in the a.out file
    
  3. ddd and gdb: examine runtime state, registers, individual instructions, memory contents

    See the week 4 lab page for more information and examples. Here are a summary of some of the most useful commands:

      ddd a.out
      (gdb) break main
      (gdb) run  6                # run with the command line argument 6
      (gdb) disass main
      (gdb) break theSwitchWay2   # set a break point at the begining of a function
      (gdb) cont
      (gdb) break *0x0804851a     # set a break point and memory address 0x0804851a
      (gdb) ni                    # execute the next instruction
      (gdb) si                    # step into a function call (step instruction)
      (gdb) info registers
      (gdb) p  *(int *)($ebp + 8)   # print out the value of an int at addr 0x88760
      (gdb) x/d $ebp + 8            # examine the contents of memory at the given address 
                                    # (interpret it as an int)
      (gdb) p %eax
    
Some more information on Tools for examining .o, .so, and a.out files
Some more information on gdb and ddd: gdb Guide

Figure 3.30 on p.255 of the textbook lists gdb commands.