As we have seen so much theory in the PART-1 now let us see a real-time example to understand about these segments. we will use size(1) command to list various section sizes in a C code.
A simple C program is given below
#include <stdio.h>
int main()
{
return 0;
}
$ gcc test.c
$ size a.out
text data bss dec hex filename
836 260 8 1104 450 a.out
Now add a global variable as shown below#include <stdio.h>
int global; /* Uninitialized variable stored in bss*/
int main()
{
return 0;
}
$ gcc test.c
$ size a.out
text data bss dec hex filename
836 260 12 1108 454 a.out
As you can see BSS is incremented by 4 bytes.