From 86640816e8b1d3595365f1fcc8a2a9e61fb40ff1 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Thu, 15 Aug 2024 10:43:19 +0200 Subject: [IMP] MHR-28: Zero memory on BSS regions. Signed-off-by: Amlal EL Mahrouss --- Boot/Sources/Thread.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Boot') diff --git a/Boot/Sources/Thread.cxx b/Boot/Sources/Thread.cxx index 6a3e8797..5bd18b19 100644 --- a/Boot/Sources/Thread.cxx +++ b/Boot/Sources/Thread.cxx @@ -83,6 +83,7 @@ namespace Boot constexpr auto sectionForCode = ".text"; constexpr auto sectionForNewLdr = ".ldr"; + constexpr auto sectionForBSS = ".bss"; for (SizeT sectIndex = 0; sectIndex < numSecs; ++sectIndex) { @@ -93,6 +94,10 @@ namespace Boot fStartAddress = (VoidPtr)((UIntPtr)loadStartAddress + optHdr->mAddressOfEntryPoint); writer.Write("newosldr: Start Address: ").Write((UIntPtr)fStartAddress).Write("\r"); } + else if (StrCmp(sectionForBSS, sect->mName) == 0) + { + SetMem((VoidPtr)(loadStartAddress + sect->mVirtualAddress), 0, sect->mSizeOfRawData); + } else if (StrCmp(sectionForNewLdr, sect->mName) == 0) { struct HANDOVER_INFORMATION_STUB @@ -111,7 +116,6 @@ namespace Boot writer.Write("newosldr: offset ").Write(sect->mPointerToRawData).Write(" of ").Write(sect->mName).Write("\r"); - SetMem((VoidPtr)(loadStartAddress + sect->mVirtualAddress), 0, sect->mSizeOfRawData); CopyMem((VoidPtr)(loadStartAddress + sect->mVirtualAddress), (VoidPtr)((UIntPtr)fBlob + sect->mPointerToRawData), sect->mSizeOfRawData); } } -- cgit v1.2.3