Search⌘ K
AI Features

Disassembly Output Without Optimization

Explore how to disassemble a simple C/C++ program in GDB without compiler optimization. Learn to reconstruct approximate source code by examining pointer operations and memory updates. This lesson helps you practice essential GDB commands for compiling, breakpoint setting, running, disassembling, and exiting to analyze program behavior step-by-step.

Example of disassembly output: no optimization mode

The ability to reconstruct approximate C/C++ code from code disassembly is essential for memory dump analysis and debugging.

Source code

Below is a C/C++ code that will help us reconstruct a program through GDB disassembly output.

C++
int a, b;
int *pa, *pb;
int main(int argc, char* argv[])
{
pa = &a;
pb = &b;
*pa = 1;
*pb = 1;
*pb = *pb + *pa;
++*pa;
*pb = *pb * *pa;
return 0;
}

Explanation

  • Line 1: Declares the two integer variables.
  • Line 2: Declares the two integer pointers.
  • Line 6–7: Initializes an integer pointer with the address of an integer variable.
  • Line 9–10:
...