我参考网络上的资讯
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 中吧!?
为什么呢? 谢谢指教。