[问题] C在内存的分布

楼主: gn00618777 (非常念旧)   2018-07-31 14:32:13
我参考网络上的资讯
A:
int main() {
const static int x = 1; //放于.data段唯读区
return 0;
}
B:
int main() {
return 0;
}
A的结果
text data bss dec hex filename
1103 544 8 1655 677 a.out
B的结果
text data bss dec hex filename
1099 544 8 1651 673 a.out
我在linux上 size a.out A和B的差异,照理说只有.data会有差异,为何影响到 text
而且data完全没变动? 我甚至宣告一个
int a[] = {1,2,3}; 一样会影响到 text, 这个区域变量应该算是在 stack 中吧!?
为什么呢? 谢谢指教。
作者: sarafciel (Cattuz)   2018-07-31 16:26:00
size --format=SysV [objfile]
楼主: gn00618777 (非常念旧)   2018-07-31 18:25:00
谢谢你

Links booklink

Contact Us: admin [ a t ] ucptt.com