Clearing sbss/bss at bootup

Konstantin Belousov kostikbel at gmail.com
Mon Apr 20 08:18:13 UTC 2015


On Sun, Apr 19, 2015 at 10:12:05PM -0700, Justin Hibbits wrote:
> Been looking at bootup issues on the e500, and many of the issues I
> see are caused by static variables not being initialized to 0 early
> enough.  The code doesn't bzero() the bss/sbss until pretty late in
> bootup.  Is there a reason why that is?  Why can't the bss be cleared
> immediately?  Do loaders pass in data at addresses that may overlap
> the bss?

I thought that bss is cleared by ELF loader code from the boot loader.
I.e. the kernel runs from the very start with the assumption that bss
is correct.

See e.g. line 427 in sys/boot/common/load_elf.c for the shared object-style
kernel/modules, and line 288 in sys/boot/common/load_elf_obj.c for
the relocatable objects.

Does your platform use FreeBSD loader ?


More information about the freebsd-ppc mailing list