From 047b4d4af4306bac1ce0eb40b18f960aa08f2f01 Mon Sep 17 00:00:00 2001 From: Mike Beaton Date: Wed, 24 Apr 2024 23:23:29 +0100 Subject: [PATCH] OpenDuet: Re-use DEBUG EfiLdr in NOOPT build NOOPT EfiLdr is too large to fit in 0x10000-x020000 allotted space, but we would like to be able to debug everything else in NOOPT. By re-using DEBUG build EfiLdr in NOOPT, we can. In fairness, this is a horrible hack - in particular it requires DEBUG OpenDuet to be built before NOOPT - but it works with the current build system, and has the arguable advantage of not affecting non-NOOPT builds at all. --- OpenDuetPkg.dsc | 3 +++ build_duet.tool | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/OpenDuetPkg.dsc b/OpenDuetPkg.dsc index 3267f605..82021d3c 100644 --- a/OpenDuetPkg.dsc +++ b/OpenDuetPkg.dsc @@ -180,7 +180,10 @@ MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf OpenCorePkg/Legacy/BootPlatform/SmbiosGenDxe/SmbiosGen.inf +!if $(TARGET) != NOOPT + # We will reuse DEBUG EfiLdr in NOOPT build to keep within allotted 0x10000-0x20000 space. OpenCorePkg/Legacy/BootPlatform/EfiLdr/EfiLdr.inf +!endif OpenCorePkg/Legacy/BootPlatform/BdsDxe/BdsDxe.inf { PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf diff --git a/build_duet.tool b/build_duet.tool index 309e7e56..e3cc2c3b 100755 --- a/build_duet.tool +++ b/build_duet.tool @@ -36,8 +36,12 @@ imgbuild() { "${BUILD_DIR_ARCH}/DxeIplUe.raw" || exit 1 echo "Generating Loader Image..." - - ImageTool GenImage -c PE -x -b 0x10000 -o "${BUILD_DIR_ARCH}/EfiLoaderRebased.efi" "${BUILD_DIR_ARCH}/EfiLoader.efi" || exit 1 + # Reuse DEBUG EfiLdr in NOOPT build to keep within allotted 0x10000-0x20000 space. + # With this approach, everything after EfiLdr is fully NOOPT, but EfiLdr starts. + # TODO: Look at moving EFILDR_BASE_SEGMENT (see also kBoot2Segment, BASE_ADDR_32) + # to make space for NOOPT loader. + SAFE_LOADER=$(echo "${BUILD_DIR_ARCH}/EfiLoader.efi" | sed -e 's/NOOPT/DEBUG/') + ImageTool GenImage -c PE -x -b 0x10000 -o "${BUILD_DIR_ARCH}/EfiLoaderRebased.efi" "${SAFE_LOADER}" || exit 1 "${FV_TOOLS}/EfiLdrImage" -o "${BUILD_DIR}/FV/Efildr${arch}" \ "${BUILD_DIR_ARCH}/EfiLoaderRebased.efi" "${BUILD_DIR}/FV/DxeIpl${arch}.z" \