Exploring Stack in GDB
Explore stack in GDB disassembly output.
Simple stack in GDB
To see the call stack in action, we’ll use a project called SimpleStack
.
Source code
The source code of the stack is given below:
Simple stack
The code for the simple stack is:
Press + to interact
void func();int main(int argc, char* argv[]){func();return 0;}
We define three functions func
, func2
, and func3
as below:
Method func
The code for func
is:
Press + to interact
void func2();void func(){func2();}
Method func2
The code for func2
is:
Press + to interact
void func3();void func2(){func3();}
Method func3
The code for func3
is:
Press + to interact
void func3(){__asm__ volatile("int $0x03");}
Compilation and execution of code:
We compile the files and load the executable into GDB:
gcc SimpleStack.c func.c func2.c func3.c -o SimpleStack
gdb ./SimpleStack
Note: You can practice all ...