From ecffd80ba20e9e2845da90ee0f921e02f5959c74 Mon Sep 17 00:00:00 2001 From: Stephen Miller Date: Sat, 3 May 2025 21:27:24 -0500 Subject: [PATCH] Swap module mapping to NoFlags, remove offset code Since real hardware has no gap between module mappings, the Fixed flag is just an annoyance to work around, and has no impact on the actual mappings. Swapping the module mappings to use flags NoFlags instead simplifies our code slightly. --- src/core/module.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/module.cpp b/src/core/module.cpp index 07211d042..440585d1a 100644 --- a/src/core/module.cpp +++ b/src/core/module.cpp @@ -20,7 +20,6 @@ namespace Core { using EntryFunc = PS4_SYSV_ABI int (*)(size_t args, const void* argp, void* param); static constexpr u64 ModuleLoadBase = 0x800000000; -static u64 LoadOffset = 0; static u64 GetAlignedSize(const elf_program_header& phdr) { return (phdr.p_align != 0 ? (phdr.p_memsz + (phdr.p_align - 1)) & ~(phdr.p_align - 1) @@ -113,9 +112,8 @@ void Module::LoadModuleToMemory(u32& max_tls_index) { // Map module segments (and possible TLS trampolines) void** out_addr = reinterpret_cast(&base_virtual_addr); - memory->MapMemory(out_addr, ModuleLoadBase + LoadOffset, aligned_base_size + TrampolineSize, - MemoryProt::CpuReadWrite, MemoryMapFlags::Fixed, VMAType::Code, name, true); - LoadOffset += aligned_base_size + TrampolineSize; + memory->MapMemory(out_addr, ModuleLoadBase, aligned_base_size + TrampolineSize, + MemoryProt::CpuReadWrite, MemoryMapFlags::NoFlags, VMAType::Code, name, true); LOG_INFO(Core_Linker, "Loading module {} to {}", name, fmt::ptr(*out_addr)); #ifdef ARCH_X86_64