Fix: Initialize .bss in sp environment startup code
Clear .bss on SP startup to have a clear starting point regardless of
the behavior of the loader. The code relies on having the .bss filled
with zeroes on startup, otherwise it will result in undefined behavior.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: Ic5cdafc2a041b0e709cd8e8acb59caa45957fa1d
diff --git a/environments/sp/sp.ld.S b/environments/sp/sp.ld.S
index e0380e3..7a57a97 100644
--- a/environments/sp/sp.ld.S
+++ b/environments/sp/sp.ld.S
@@ -2,7 +2,7 @@
/*
* Copyright (c) 2014, STMicroelectronics International N.V. All rights reserved.
* Copyright (c) 2015, Linaro Limited. All rights reserved.
- * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2023, Arm Limited and Contributors. All rights reserved.
*/
#ifdef ARM32
OUTPUT_FORMAT("elf32-littlearm")
@@ -92,7 +92,9 @@
.data : { *(.data .data.* .gnu.linkonce.d.*) }
.bss : {
+ __bss_start = .;
*(.bss .bss.* .gnu.linkonce.b.* COMMON)
+ __bss_end = .;
}
.stack : {
. = ALIGN(4);