From 5c5cf2f8e000d1bf4fc12ff20351aa60367cb563 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Thu, 9 Jul 2015 22:52:15 -0300 Subject: Core: Properly configure address space when loading a binary The code now properly configures the process image to match the loaded binary segments (code, rodata, data) instead of just blindly allocating a large chunk of dummy memory. --- src/core/hle/kernel/vm_manager.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/core/hle/kernel/vm_manager.cpp') diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index ec437cd6..205cc7b5 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -35,6 +35,10 @@ VMManager::VMManager() { Reset(); } +VMManager::~VMManager() { + Reset(); +} + void VMManager::Reset() { vma_map.clear(); @@ -130,6 +134,16 @@ void VMManager::Reprotect(VMAHandle vma_handle, VMAPermission new_perms) { MergeAdjacent(iter); } +void VMManager::LogLayout() const { + for (const auto& p : vma_map) { + const VirtualMemoryArea& vma = p.second; + LOG_DEBUG(Kernel, "%08X - %08X size: %8X %c%c%c", vma.base, vma.base + vma.size, vma.size, + (u8)vma.permissions & (u8)VMAPermission::Read ? 'R' : '-', + (u8)vma.permissions & (u8)VMAPermission::Write ? 'W' : '-', + (u8)vma.permissions & (u8)VMAPermission::Execute ? 'X' : '-'); + } +} + VMManager::VMAIter VMManager::StripIterConstness(const VMAHandle & iter) { // This uses a neat C++ trick to convert a const_iterator to a regular iterator, given // non-const access to its container. -- cgit v1.2.3