Browse Source

boot: zero bss after jump to C entry point

K. Lange 2 years ago
parent
commit
38691a2f01
2 changed files with 5 additions and 0 deletions
  1. 3 0
      boot/cstuff.c
  2. 2 0
      boot/link.ld

+ 3 - 0
boot/cstuff.c

@@ -110,7 +110,10 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
 	ST = SystemTable;
 	ImageHandleIn = ImageHandle;
 #else
+extern char _bss_start[];
+extern char _bss_end[];
 int kmain() {
+	memset(&_bss_start,0,(uintptr_t)&_bss_end-(uintptr_t)&_bss_start);
 #endif
 
 	BOOT_OPTION(_debug,       0, "Debug output",

+ 2 - 0
boot/link.ld

@@ -28,10 +28,12 @@ SECTIONS
 
 	.bss BLOCK(1) : ALIGN(1)
 	{
+		PROVIDE(_bss_start = .);
 		bss = .;
 		*(COMMON)
 		*(.bss)
 		*(.stack)
+		PROVIDE(_bss_end = .);
 	}
 
 	end = .;