Have Locore zero out the bss (which includes our stack) BEFORE

we start calling into C code. Previously we called memset() in our
C code. Unfortunately the compiler would sometimes store local variables
on the statck, which got killed by the memset(). Oops!
This commit is contained in:
wrstuden 2004-03-17 23:32:22 +00:00
parent 5284eba6e3
commit 58472c3385
2 changed files with 20 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: Locore.c,v 1.15 2003/12/26 13:43:29 aymeric Exp $ */
/* $NetBSD: Locore.c,v 1.16 2004/03/17 23:32:22 wrstuden Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -89,7 +89,23 @@ asm(
" mtmsr %r8 \n"
" isync \n"
" \n"
" b startup \n"
/*
* Make sure that .bss is zeroed
*/
" \n"
" li %r0,0 \n"
" lis %r8,_edata@ha \n"
" addi %r8,%r8,_edata@l\n"
" lis %r9,_end@ha \n"
" addi %r9,%r9,_end@l \n"
" \n"
"5: cmpw 0,%r8,%r9 \n"
" bge 6f \n"
" stw %r0,0(%r8) \n"
" addi %r8,%r8,4 \n"
" b 5b \n"
" \n"
"6: b startup \n"
);
#if 0
@ -108,7 +124,6 @@ startup(void *vpd, int res, int (*openfirm)(void *), char *arg, int argl)
{
extern char etext[], _end[], _edata[];
memset(_edata, 0, (_end - _edata));
openfirmware = openfirm;
setup();
main();

View File

@ -1,4 +1,4 @@
$NetBSD: version,v 1.8 2004/03/17 20:41:17 wrstuden Exp $
$NetBSD: version,v 1.9 2004/03/17 23:32:22 wrstuden Exp $
1.1: Initial revision from NetBSD/powerpc.
1.2: Use MI loadfile().
@ -9,3 +9,4 @@ $NetBSD: version,v 1.8 2004/03/17 20:41:17 wrstuden Exp $
1.6: Support ustarfs.
1.7: Go back to using OFW-specific alloc.c.
1.8: Change load address to E00000 to support kernels over 5MB big
1.9: Zero out the stack before we call into C code.