我今天写了这个小程序,我对结果感到震惊.这是程序
int main(int argc, char **argv)
{
int a;
printf("\n\tMain is located at: %p and the variable a is located at address: %p",main,&a);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在我的机器上,主函数总是加载在地址"0x80483d4"并且变量的地址保持不变这是怎么发生的?我在操作系统中读到,作为虚拟化方案的一部分,操作系统不断重新定位指令地址.那么为什么每次我运行这个程序时主要加载到同一个地址呢?
先谢谢你们.