gcc全局数据内存布局规则

发布于 2024-12-27 15:25:17 字数 216 浏览 4 评论 0原文

我知道这不是(也不必)标准化,但我想知道 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

德意的啸 2025-01-03 15:25:17

你什么也做不了。链接器可以做任何它想做的事情来优化布局。

You can't make any. The linker can do whatever it wants in optimizing the layout.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文