I developed a simple C program as shown below..
int main()
{
return 0;
}
I compiled the program using gcc v5.2.1. When I ran the Unix command 'size' on the executable below are the sizes it displayed..
text = 1131, data = 552, bss = 8
As per my understanding the data section hold initialized global data and BSS holds uninitialized global data. Though there are no global variables why do the 'data' and 'BSS' section show non-zero values?
In a nutshell: Because your final program has more code than just the part you write. It must contain some runtime that e.g. does all the setup required before it can call main() (like populating argv, initializing data in .bss to zero, and so on) as well as cleanup after exit. What exactly is done in this code depends entirely on your implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With