Clearing sbss/bss at bootup

Justin Hibbits jrh29 at po.cwru.edu
Sun Apr 26 03:25:12 UTC 2015


On Apr 20, 2015 4:38 AM, "Konstantin Belousov" <kostikbel at gmail.com> wrote:
>
> 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 ?

No, the RouterBoard uses a custom loader. It doesn't seem to have any
guarantees of initialization.

- Justin


More information about the freebsd-ppc mailing list