From 65c9bf56f597e46bdf9d0acb5c46832a41366db0 Mon Sep 17 00:00:00 2001 From: Thomas Oltmann Date: Thu, 17 Jul 2025 07:09:21 +0200 Subject: [PATCH] Separate BSS section, cleared manually at runtime. --- Makefile | 2 +- fernlader.ld | 8 +++++++- lboot.S | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index edd51a3..ccb35cf 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ config.mk: | config.default.mk cp config.default.mk $@ boot.bin: boot.elf - objcopy -O binary --only-section=.text boot.elf $@ + objcopy -O binary -j .text -j .data boot.elf $@ boot.elf: lboot.o loader.o fernlader.ld $(LD) $(LDFLAGS) -o $@ lboot.o loader.o diff --git a/fernlader.ld b/fernlader.ld index abcf9ac..4b32b5c 100644 --- a/fernlader.ld +++ b/fernlader.ld @@ -6,9 +6,15 @@ SECTIONS { .text 0x7C00: { lboot.o(.text) *(.text, .rodata*) + } :all + .data : { *(.data) - *(.bss, COMMON) . = ALIGN(4K); lboot.o(.data.bootboot) } :all + _bss_start = .; + .bss (NOLOAD) : { + *(.bss, COMMON) + } :all + _bss_end = .; } diff --git a/lboot.S b/lboot.S index c5977e2..5106227 100644 --- a/lboot.S +++ b/lboot.S @@ -57,6 +57,12 @@ _start: cli mov %ax, %ds mov %ax, %es + mov $_bss_start, %di + mov $_bss_end, %cx + sub %di, %cx + xor %al, %al + rep stosb + call init_com1 mov $msg_start, %si @@ -122,7 +128,7 @@ _start: cli mov $msg_long, %si call print - jmp hang // REMOVE ME + //jmp hang // REMOVE ME call long jmp hang