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.
This commit is contained in:
Yuri Kunde Schlesner
2015-07-09 22:52:15 -03:00
parent 51820691e7
commit 5c5cf2f8e0
11 changed files with 223 additions and 52 deletions

View File

@ -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.