Bss Section Elf
The bss the section named bss is in the simplest way of describing it.
Bss section elf. As the image above shows a segment can have 0 or more sections. Uninitialized static and global variable stored in bss segment. Elf file header see struct elf32 ehdr struct elf64 ehdrin usr include elf h and one or more program headers see struct elf32 phdr struct elf64 phdrin usr include elf h usually there is another kind of header called section header which describe.
The linux kernel manages to sort that out. Finally the bss section is not necessarily adjacent to the data section or the heap. Sections can be found in an elf binary after the gnu c compiler transformed c code into assembly followed by the gnu assembler which creates objects of it.
If you check the linux kernel more in particular the load elf binary function you can see that the bss sections or more precisely the segment it maps to may even be interleaved with code and initialized data. A block of memory which has been zeroed. Initialized static and global variable stored in data segment.
An elf file is divided into sections. The elf file contains headers that describe how these sections should be stored in memory. The bss is the area in memory where variables with global lifetime that haven t been initialized or have been initialized to 0 or null are stored.
For executable files there are four main sections. The bss segment contains all global variables and static variables that are initialized to zero or do not have explicit initialization in source code. In code size information with gcc for arm kinetis i use an option in the arm gcc tool chain for eclipse to show me the code size.
Typically only the length of the bss section but no data is stored in the. For instance a variable defined as static int i. Memory layout of c program code data bss stack and heap segments.