Karthik Balaguru
Karthik Balaguru

Reputation: 7842

How does the BSS segment manage to hold the details if it does not occupy any file size?

The ELF specification conveys that the .bss section does not occupy any file size. I wonder then, how does it manage to hold the details if it does not occupy any file size ? Please clarify me.

Upvotes: 1

Views: 365

Answers (1)

Anon
Anon

Reputation: 2348

You do not quote the section of the ELF specification, and when I searched I did not find "BSS" identified explicitly, so I'll quote the Wikipedia entry for BSS:

In computer programming, the name .bss or bss is used by many compilers and linkers for a part of the data segment containing statically-allocated variables represented solely by zero-valued bits initially (i.e., when execution begins). It is often referred to as the "bss section" or "bss segment".

And the answer is simple: if you know that all values will be initialized to zero, there's no need to explicitly specify those values in the executable file.

Upvotes: 1

Related Questions