1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

LibELF: Unmap and close the main executable after dynamic load

We don't need to keep the whole main executable in memory after
completing the dynamic loading process. We can also close the fd.
This commit is contained in:
Andreas Kling 2021-02-13 13:46:20 +01:00
parent 5b891b0c36
commit 40a5487bab
Notes: sideshowbarker 2024-07-18 22:22:08 +09:00
2 changed files with 14 additions and 3 deletions

View file

@ -87,8 +87,14 @@ DynamicLoader::DynamicLoader(int fd, String filename, void* data, size_t size)
DynamicLoader::~DynamicLoader()
{
munmap(m_file_data, m_file_size);
close(m_image_fd);
if (munmap(m_file_data, m_file_size) < 0) {
perror("munmap");
ASSERT_NOT_REACHED();
}
if (close(m_image_fd) < 0) {
perror("close");
ASSERT_NOT_REACHED();
}
}
const DynamicObject& DynamicLoader::dynamic_object() const