LibELF: Optimize LoadableELF::clone() memory usage

We only clone mapped pages that have been marked as writeble.
Read/execute only pages will be exactly as in the file itself and
can be demand paged also :D
This commit is contained in:
Bananymous 2023-09-29 02:05:12 +03:00
parent 603fc200e6
commit 7e9e4c47ae
1 changed files with 3 additions and 0 deletions

View File

@ -252,6 +252,9 @@ namespace LibELF
break;
case PT_LOAD:
{
if (!(program_header.p_flags & LibELF::PF_W))
continue;
PageTable::flags_t flags = PageTable::Flags::UserSupervisor | PageTable::Flags::Present;
if (program_header.p_flags & LibELF::PF_W)
flags |= PageTable::Flags::ReadWrite;