]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[riscv] Place explicitly zero-initialised variables in the .data section
authorMichael Brown <mcb30@ipxe.org>
Wed, 30 Jul 2025 12:14:21 +0000 (13:14 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 30 Jul 2025 12:15:11 +0000 (13:15 +0100)
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>
src/arch/riscv/Makefile.sbi

index d748ef42eb386eaea4e64f37dbe3a52b2d00a288..5e5dc9a6ba07ed1a582d14c45d2535f2d37a529b 100644 (file)
@@ -7,6 +7,13 @@
 CFLAGS         += -mcmodel=medany -fpie
 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
 #
 LDSCRIPT       = arch/riscv/scripts/sbi.lds