Memory Pointers Project: Memory Layout
Learn how to use pointers to manipulate memory.
Memory pointers in C/C++
We have the following data declaration and definition in C/C++:
Memory pointers in assembly language
The project code corresponds to the following pseudocode and assembly language instructions.
Source code
The source code of memory pointers is following:
Memory pointers in GDB disassembly
Our memory pointers project is described in detail below.
Compile and execute GDB commands
First, we need to compile and link the course code and load the executable into GDB. We get to the GDB environment with the following commands.
Note: You can practice all the commands in the coding playground provided at the end of the lesson.
After running the above commands, the output should be as follows:
We put a breakpoint in the main function, run the program until GDB breaks in, and then disassemble the main function:
break main
A breakpoint is shown below:
Now run the program:
set disable-randomization off
run
The output after execution is given below:
Now we disassemble the ...