Previously, we were assuming that everything from the end of .data to the
end of the kernel image was .bss.  That is definitely not the case, which
becomes apparent if you try to add an attribute for another section and
then you wonder why said section is zeroed at runtime (but not in the
object!).

Signed-off-by: Barret Rhoden <[email protected]>
---
 kern/arch/riscv/kernel.ld | 2 ++
 kern/arch/x86/kernel64.ld | 2 ++
 kern/src/init.c           | 4 ++--
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/kern/arch/riscv/kernel.ld b/kern/arch/riscv/kernel.ld
index 126b8bf7a5b8..c2c92057bc60 100644
--- a/kern/arch/riscv/kernel.ld
+++ b/kern/arch/riscv/kernel.ld
@@ -53,8 +53,10 @@ SECTIONS
        PROVIDE(edata = .);
 
        .bss : {
+               PROVIDE(__start_bss = .);
                *(.bss)
                *(.sbss)
+               PROVIDE(__stop_bss = .);
        }
 
        PROVIDE(end = .);
diff --git a/kern/arch/x86/kernel64.ld b/kern/arch/x86/kernel64.ld
index 06562979378e..f37a095d7e50 100644
--- a/kern/arch/x86/kernel64.ld
+++ b/kern/arch/x86/kernel64.ld
@@ -56,8 +56,10 @@ SECTIONS
        PROVIDE(edata = .);
 
        .bss : {
+               PROVIDE(__start_bss = .);
                *(.bss)
                *(COMMON)
+               PROVIDE(__stop_bss = .);
        }
 
        PROVIDE(end = .);
diff --git a/kern/src/init.c b/kern/src/init.c
index 67502c688050..5b2e9d2c65d0 100644
--- a/kern/src/init.c
+++ b/kern/src/init.c
@@ -119,9 +119,9 @@ static void extract_multiboot_cmdline(struct multiboot_info 
*mbi)
 
 void kernel_init(multiboot_info_t *mboot_info)
 {
-       extern char edata[], end[];
+       extern char __start_bss[], __stop_bss[];
 
-       memset(edata, 0, end - edata);
+       memset(__start_bss, 0, __stop_bss - __start_bss);
        /* mboot_info is a physical address.  while some arches currently have 
the
         * lower memory mapped, everyone should have it mapped at kernbase by 
now.
         * also, it might be in 'free' memory, so once we start dynamically 
using
-- 
2.6.0.rc2.230.g3dd15c0

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to