mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +00: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:
parent
5b891b0c36
commit
40a5487bab
2 changed files with 14 additions and 3 deletions
|
@ -257,7 +257,9 @@ void ELF::DynamicLinker::linker_main(String&& main_program_name, int main_progra
|
|||
allocate_tls();
|
||||
|
||||
load_elf(main_program_name);
|
||||
auto main_program_lib = commit_elf(main_program_name);
|
||||
|
||||
// NOTE: We put this in a RefPtr instead of a NonnullRefPtr so we can release it later.
|
||||
RefPtr main_program_lib = commit_elf(main_program_name);
|
||||
|
||||
FlatPtr entry_point = reinterpret_cast<FlatPtr>(main_program_lib->image().entry().as_ptr());
|
||||
if (main_program_lib->is_dynamic())
|
||||
|
@ -272,6 +274,9 @@ void ELF::DynamicLinker::linker_main(String&& main_program_name, int main_progra
|
|||
asm("int3");
|
||||
}
|
||||
|
||||
// Unmap the main executable and release our related resources.
|
||||
main_program_lib = nullptr;
|
||||
|
||||
int rc = syscall(SC_msyscall, nullptr);
|
||||
if (rc < 0) {
|
||||
ASSERT_NOT_REACHED();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue