From fb916a4c336c2bd82666d08e8b04bb2d1123968a Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 5 Nov 2022 13:55:17 +0100 Subject: [PATCH] Boot: Load DOL/ELF after memory setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I recently talked to a homebrew developer who was trying to add exception handlers at link time but found out that Dolphin was overwriting their exception handlers. I figure that's not the usual way to do exception handlers, but... making us load the executable after setting up memory rather than before is easy, and matches what we do when booting discs, so I suppose there's no reason not to do it. It also matches the intent of why Dolphin is writing default exception handlers – we're writing them because some homebrew relies on exception handlers being left around from whatever program was running before it (see 3dd777be70). --- Source/Core/Core/Boot/Boot.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index f2ee8da546..a80aa4d719 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -540,12 +540,6 @@ bool CBoot::BootUp(std::unique_ptr boot) if (!executable.reader->IsValid()) return false; - if (!executable.reader->LoadIntoMemory()) - { - PanicAlertFmtT("Failed to load the executable to memory."); - return false; - } - SetDefaultDisc(); SetupMSR(); @@ -569,6 +563,12 @@ bool CBoot::BootUp(std::unique_ptr boot) SetupGCMemory(); } + if (!executable.reader->LoadIntoMemory()) + { + PanicAlertFmtT("Failed to load the executable to memory."); + return false; + } + SConfig::OnNewTitleLoad(); PC = executable.reader->GetEntryPoint();