Xin*_*ang 0 c memory memory-management
在64位机器中,我编写了一个简单的C程序,如下所示:
#include <stdio.h>
int main(int argc,char* argv[])
{
printf("Hello,world!\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
然后gcc hello.c -o hello,size hello,我得到了:
text data bss dec hex filename
1156 492 16 1664 680 hello
Run Code Online (Sandbox Code Playgroud)
接下来,我在源代码中添加一个全局int变量:
#include <stdio.h>
int global;
int main(int argc,char* argv[])
{
printf("Hello,world!\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
再次编译和大小,我得到:
text data bss dec hex filename
1156 492 24 1672 688 hello
Run Code Online (Sandbox Code Playgroud)
所以,问题是,bss段增加了8个字节,但为什么呢?只添加了一个int变量global.那应该是4.
BTW,gcc版本是4.4.7