I am having some troubles with my learning of Assembly and reverse engineering. Specifically, I am learning about Global vs Local variables. For Global variables I have managed to get insights in assembly that they are stored in memory address. For Local variables I expect them to be stored on stack (theory), but my simple C code below, when being disassembled in Ghidra, does not show anything in main function.
C CODE:
void main()
{
int x = 1;
int y = 2;
x = x + y;
}
GHIDRA OUTPUT:
Why can't I see anything in my Ghidra? It looks like an empty function to me, but clearly there should be some local variable declaration and then addition performed afterwards.
I really apologize for opening threads here often, but this is the only source where I can get help for such things. On Reddit they do not allow posting questions and referred me here.
EDIT - 25.09.2019:
As per suggestion I have added some code to my existing C Code to see if it will show up now in Assembly:
#include <stdio.h>
void main()
{
int x = 1;
int y = 2;
x = x + y;
printf("Rezultat = %d\n", x);
}
For this I had to set entry point back to CRT initialize, otherwise I could not use stdio Library. This is now the result of main function in Ghidra:
Now I am able to see the PUSH instruction and the value 0x03. This is probably the resulting value of addition 1 + 2, but I again can't nowhere see where are the local variables initialized nor where the arithmetic operation is performed.
add(1, 2);
.volatile
? Example:volatile int x = 1;