In said:
(e-mail address removed) (Dan Pop) wrote in
Which I always thought was a misnomer as the block is zeroed.
The idea is that there is no image for this segment in the executable
file. It comes already zeroed by the OS, as any piece of memory obtained
from the OS, for obvious security reasons.
I suppose it
means the programmer did not initialize items in this segment.
Anything initialised to all zeroes *by default* gets there. If you
initialise to all zeroes explicitly, the stuff goes into the data
segment and actually increases the executable size. At least, this is
what gcc is doing:
fangorn:~/tmp 262> cat default.c
int a[10000];
int main()
{
return 0;
}
fangorn:~/tmp 263> gcc default.c
fangorn:~/tmp 264> ls -l a.out
-rwxr-xr-x 1 danpop sysprog 13214 Nov 26 17:10 a.out*
fangorn:~/tmp 265> size a.out
text data bss dec hex filename
839 220 40032 41091 a083 a.out
fangorn:~/tmp 266> cat explicit.c
int a[10000] = {0};
int main()
{
return 0;
}
fangorn:~/tmp 267> gcc explicit.c
fangorn:~/tmp 268> ls -l a.out
-rwxr-xr-x 1 danpop sysprog 53263 Nov 26 17:11 a.out*
fangorn:~/tmp 269> size a.out
text data bss dec hex filename
839 40240 24 41103 a08f a.out
I certainly didn't expect that!
Dan