Re: initializing the .bss area

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



JJ <alchemistmba@xxxxxxxxx> writes:

> I'm writing a custom _start function in assembly. I'm using some old
> code as reference. It zeroes out the .bss area. I checked the
> disassembly of the generated binary and the bss area contains 0x0 by
> default. From what I read online, the bss area contains the
> uninitialized variables. If thats the case, isn't it fine to not
> explicitly initialize this in the _start?

The contents of the .bss section must contain zeroes when the program
starts to run.  Typically a binary does not actually include the .bss
section, it just specifies how large it is (in ELF this is done in the
program header by having p_memsz be larger than p_filesz).  If your
binary includes zeroes for the .bss section for some reason, then you
don't have to do anything further.  If your memory is guaranteed to be
zeroes for whatever reason, then you don't have to do anything
further.  In a typical embedded system neither is true, in which case
the startup code must explicitly zero the .bss section before jumping
to the program proper.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux