Skip to content
Snippets Groups Projects
Commit 3cc80f7f authored by Avi Kivity's avatar Avi Kivity
Browse files

boot: initialize .bss

Previously, the boot code assumed (by omission) that memory is initialized
to zero.  Apparently that is not the case, and this caused memory to become
corrupted.

Initialize .bss to zero to fix.
parent 793f312b
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ tr: .word tss_desc - gdt ...@@ -45,7 +45,7 @@ tr: .word tss_desc - gdt
.globl start32 .globl start32
start32: start32:
mov %eax, elf_header mov %eax, %ebp
lgdt gdt_desc lgdt gdt_desc
mov $0x10, %eax mov $0x10, %eax
mov %eax, %ds mov %eax, %ds
...@@ -74,5 +74,11 @@ start64: ...@@ -74,5 +74,11 @@ start64:
movb %dl, tss_desc + 4 movb %dl, tss_desc + 4
movb %dh, tss_desc + 7 movb %dh, tss_desc + 7
ltr tr ltr tr
lea .bss, %rdi
lea .edata, %rcx
sub %rdi, %rcx
xor %eax, %eax
rep stosb
mov %rbp, elf_header
jmp main jmp main
...@@ -18,6 +18,7 @@ SECTIONS ...@@ -18,6 +18,7 @@ SECTIONS
.init_array : { *(.init_array) } :text .init_array : { *(.init_array) } :text
_init_array_end = .; _init_array_end = .;
.bss : { *(.bss) } :text .bss : { *(.bss) } :text
.edata = .;
} }
PHDRS { PHDRS {
text PT_LOAD FILEHDR PHDRS; text PT_LOAD FILEHDR PHDRS;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment