c - Different programs, same variables, same address in memory -
i have 2 c codes. test.c
#include <stdlib.h> int main () { int a; = 5; return a; }
test2.c is
#include <stdlib.h> int main () { int a; = 6; return a; }
when run them , check address in memory of "a"s gdb same address. why so?
breakpoint 1, main () @ test.c:7 7 return a; (gdb) print &a $1 = (int *) 0x7fffffffe1cc
breakpoint 1, main () @ test2.c:7 7 return a; (gdb) print &a $1 = (int *) 0x7fffffffe1cc
the address of "a" on stack frame program. virtual address, independent of in physical memory program loaded. therefore, not surprising if both (almost identical) programs used same address.
Comments
Post a Comment