Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux assembly; bss section memory initialized to 0?

In tests I have run the memory in the bss section of my programs has always been initialized to zero before I write anything there. Is this coincidental, or is the system "cleaning" these memory pages before handing them to me? I am using the nasm assembler on Ubuntu (if that possibly makes a difference).

like image 582
kasterma Avatar asked Mar 15 '26 06:03

kasterma


1 Answers

Your application's executable file(ELF) has a BSS section's size information, when it starts up, kernel allocate a block of memory for BSS section, and clean it to 0. This defined by ABI(Application Binary Interface), so you needn't worry about there are different on different machine.

like image 100
Huang F. Lei Avatar answered Mar 17 '26 21:03

Huang F. Lei