Restored clearing of the bss, except for putting it in a correct place

with up to date comments.  This fixes booting kernels with boot2
(except for loss of the features provided by loader) and is suitable
for MFC.  Contrary to the old comments, most loaders don't clear the bss.
biosboot lost clearing of the bss in a code crunch in 1997, and boot2
never did it.

kan didn't notice the problem with gcc-3.3 putting variables that are
initialized to 0 in the bss until after committing gcc-3.3 because he
was already using essentially this patch.  Before gcc-3.3, only the
non-critical `bootdev' variable was clobbered by clearing the bss.

MFC after:	3 days
This commit is contained in:
bde 2003-07-29 21:57:01 +00:00
parent 692df0c688
commit b722789df3

View File

@ -235,6 +235,24 @@ NON_GPROF_ENTRY(btext)
mov %ax, %fs
mov %ax, %gs
/*
* Clear the bss. Not all boot programs do it, and it is our job anyway.
*
* XXX we don't check that there is memory for our bss and page tables
* before using it.
*
* Note: we must be careful to not overwrite an active gdt or idt. They
* inactive from now until we switch to new ones, since we don't load any
* more segment registers or permit interrupts until after the switch.
*/
movl $R(end),%ecx
movl $R(edata),%edi
subl %edi,%ecx
xorl %eax,%eax
cld
rep
stosb
call recover_bootinfo
/* Get onto a stack that we can trust. */
@ -273,15 +291,6 @@ NON_GPROF_ENTRY(btext)
#endif
call identify_cpu
/*
* We used to clear BSS here, but it isn't needed anymore and actually
* causes harm. gcc now optimizes 'int foo = 0' to be uninitialized in
* the bss. All the supported loaders already zero the bss. The a.out
* kgzip case does not, but we do not generate a.out kernels anymore.
* This is trivial to fix anyway, is a bug in kgzip.
*/
call create_pagetables
/*