Prashanth L.A.
2023-08-28
Â
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
printf("location of code : %p\n", main);
printf("location of heap : %p\n", malloc(100e6));
int x = 3;
printf("location of stack: %p\n", &x);
return 0;
}
void func()
int x;
...
x = x + 3; // this is the line of code we are interested in
Hardware provide two registers: Base and Bounds
\[physical\ addr = virtual\ addr + base \]
\[virtual\ addr \le bounds\]
128: movl 0x0(%ebx), %eax
movl 1000, %eax
becomes
movl 4000, %eax