Search code examples
loader

what does the BSS segment store?


I know that the BSS segment stores the uninitialized global and static variables and initializes them to zero. But what if the global/static variable is initialized and my second question is I read that BSS segment doesn't consume memory, then where those it store these variables? Thanks


Solution

  • You probably read that the BSS segment doesn't consume space in the executable file on disk. When the executable loaded, the BSS segment certainly does consume space in memory. Space is allocated and initialised to zero by the OS loader.