1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

Kernel+LibELF: Abort ELF executable load sooner when something fails

Make it possible to bail out of ELF::Image::for_each_program_header()
and then do exactly that if something goes wrong during executable
loading in the kernel.

Also make the errors we return slightly more nuanced than just ENOEXEC.
This commit is contained in:
Andreas Kling 2020-12-25 14:42:42 +01:00
parent 791b32e3c6
commit 6c9a6bea1e
5 changed files with 52 additions and 39 deletions

View file

@ -101,6 +101,7 @@ RefPtr<DynamicObject> DynamicLoader::dynamic_object_from_image() const
if (program_header.type() == PT_DYNAMIC) {
dynamic_section_address = VirtualAddress(program_header.raw_data());
}
return IterationDecision::Continue;
});
ASSERT(!dynamic_section_address.is_null());
@ -114,6 +115,7 @@ size_t DynamicLoader::calculate_tls_size() const
if (program_header.type() == PT_TLS) {
tls_size = program_header.size_in_memory();
}
return IterationDecision::Continue;
});
return tls_size;
}
@ -232,6 +234,7 @@ void DynamicLoader::load_program_headers()
} else if (region.is_dynamic()) {
dynamic_region_desired_vaddr = region.desired_load_address();
}
return IterationDecision::Continue;
});
ASSERT(text_region_ptr && data_region_ptr);