[riscv] Place explicitly zero-initialised variables in the .data section

Variables in the .bss section cannot be relied upon to have zero
values during early initialisation, before we have relocated ourselves
to somewhere suitable in RAM and zeroed the .bss section.

Place any explicitly zero-initialised variables in the .data section
rather than in .bss, so that we can rely on their values even during
this early initialisation stage.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-07-30 13:14:21 +01:00
parent 5bda1727b4
commit a814c46059

View File

@@ -7,6 +7,13 @@
CFLAGS += -mcmodel=medany -fpie CFLAGS += -mcmodel=medany -fpie
LDFLAGS += -pie --no-dynamic-linker -z combreloc LDFLAGS += -pie --no-dynamic-linker -z combreloc
# Place explicitly zero-initialised variables in the .data section
# rather than in .bss, so that we can rely on their values even during
# parsing of the system memory map prior to relocation (and therefore
# prior to explicit zeroing of the .bss section).
#
CFLAGS += -fno-zero-initialized-in-bss
# Linker script # Linker script
# #
LDSCRIPT = arch/riscv/scripts/sbi.lds LDSCRIPT = arch/riscv/scripts/sbi.lds