Skip to content

Commit

Permalink
linker: fix map flags
Browse files Browse the repository at this point in the history
  • Loading branch information
DHrpcs3 committed Nov 17, 2024
1 parent f972e14 commit 86942b3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions rpcsx/linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,19 @@ Ref<orbis::Module> rx::linker::loadModule(std::span<std::byte> image,
phdr.p_flags |= vm::kMapProtCpuWrite; // TODO: reprotect on relocations
}

vm::protect(imageBase + segmentBegin, segmentSize,
phdr.p_flags & (vm::kMapProtCpuAll | vm::kMapProtGpuAll));
int mapFlags = 0;

if (phdr.p_flags & PF_X) {
mapFlags |= vm::kMapProtCpuExec;
}
if (phdr.p_flags & PF_W) {
mapFlags |= vm::kMapProtCpuWrite;
}
if (phdr.p_flags & PF_R) {
mapFlags |= vm::kMapProtCpuRead;
}

vm::protect(imageBase + segmentBegin, segmentSize, mapFlags);

if (phdr.p_type == kElfProgramTypeLoad) {
if (result->segmentCount >= std::size(result->segments)) {
Expand Down

0 comments on commit 86942b3

Please sign in to comment.