gcc全局数据内存布局规则
我知道这不是(也不必)标准化,但我想知道 gcc 是否有任何关于在程序内存中放置全局数据存储的规则或可预测模式。也就是说,如果我在全局范围内有一个带有 int a, b;
的 foo.c
,那么有一个带有 bar.c
>int c, d; 以类似的方式,那么我可以对编译程序的内存地址空间中的 a、b、c、d 的相对位置做出什么假设?
I know that this is not (and has not to be) standardized, but I'd like to know if gcc has any rule or predictable pattern about placing storage for global data in program memory. That is, if I have a foo.c
with int a, b;
in a global scope, then a bar.c
with int c, d;
in a similar manner, then what assumptions can I make about the relative positions of a, b, c, d in the memory address space of my compiled program?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你什么也做不了。链接器可以做任何它想做的事情来优化布局。
You can't make any. The linker can do whatever it wants in optimizing the layout.