70 likes | 163 Views
Text Segment. Source Code. void test_function ( int a) { int flag = a*a; } int main( ) { int num = 8; test_function ( num ); }. Instructions for test_function. gcc , gdb. Instructions for main. ~. ~. Text Segment. Source Code. void test_function ( int a) {
E N D
Text Segment Source Code void test_function(int a) { int flag = a*a; } int main( ) { intnum = 8; test_function(num); } Instructions for test_function gcc, gdb Instructions for main ~ ~
Text Segment Source Code void test_function(int a) { int flag = a*a; } int main( ) { intnum = 8; test_function(num); } Instructions for test_function Instructions for main eip ~ ~ ~ ~ Stack Registers esp Stack frame for main ebp
Text Segment Source Code void test_function(int a) { int flag = a*a; } int main( ) { intnum = 8; test_function(num); } Instructions for test_function Instructions for main eip ~ ~ ~ ~ Stack Registers esp Stack frame for main ebp
Text Segment Source Code void test_function(int a) { int flag = a*a; } int main( ) { intnum = 8; test_function(num); } Instructions for test_function Instructions for main eip Note: this is the address we want to return to after the function call (i.e. the return address) ~ ~ ~ ~ Stack Registers esp Stack frame for main ebp
Text Segment Source Code void test_function(int a) { int flag = a*a; } int main( ) { intnum = 8; test_function(num); } eip Instructions for test_function Instructions for main ~ ~ ~ ~ Stack Stack frame for test_function Registers Stack frame for main esp ebp
Text Segment Source Code void test_function(int a) { int flag = a*a; } int main( ) { intnum = 8; test_function(num); } eip Instructions for test_function Instructions for main ~ ~ ~ ~ Stack Stack frame for test_function Registers Stack frame for main esp ebp
Text Segment Source Code void test_function(int a) { int flag = a*a; } int main( ) { intnum = 8; test_function(num); } eip Instructions for test_function Instructions for main ~ ~ ~ ~ Stack Registers esp Stack frame for main ebp