POSIX: Use a fixed base for executable memory

This commit is contained in:
Jeffrey Pfau 2016-07-31 17:14:39 -07:00
parent e04b053b89
commit 187b4bb7d3
4 changed files with 16 additions and 3 deletions

View File

@ -160,7 +160,7 @@ elseif(UNIX)
endif()
list(APPEND CORE_VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-fd.c ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-dirent.c)
file(GLOB OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/posix/*.c)
file(GLOB OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/posix/*.[cs])
source_group("POSIX-specific code" FILES ${OS_SRC})
endif()

View File

@ -129,7 +129,7 @@ void ARMDynarecRecompileTrace(struct ARMCore* cpu, struct ARMDynarecTrace* trace
EMIT(&ctx, PUSH, AL, 0x4030);
EMIT(&ctx, MOV, AL, 4, 0);
EMIT(&ctx, LDRI, AL, 5, 0, ARM_PC * sizeof(uint32_t));
struct ARMInstructionInfo info;
__attribute__((aligned(64))) struct ARMInstructionInfo info;
while (true) {
uint16_t instruction = cpu->memory.load16(cpu, ctx.address, 0);
struct ARMDynarecLabel* label = &ctx.labels[(ctx.address - trace->start) >> 1];

View File

@ -0,0 +1,4 @@
.section .execmem,"awx",%nobits
.global _execMem
_execMem:
.space 0x800000

View File

@ -7,14 +7,23 @@
#include <sys/mman.h>
extern uint32_t _execMem;
static void* _execMemHead = &_execMem;
void* anonymousMemoryMap(size_t size) {
return mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
}
void* executableMemoryMap(size_t size) {
return mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0);
void* out = _execMemHead;
_execMemHead += size / sizeof(_execMemHead);
return out;
}
void mappedMemoryFree(void* memory, size_t size) {
if (memory < _execMemHead + 0x20000) {
_execMemHead -= size / sizeof(_execMemHead);
return;
}
munmap(memory, size);
}