mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:17:44 +00:00
LibELF: Consolidate main executable loading a bit
Merge the load_elf() and commit_elf() functions into a single load_main_executable() function that takes care of both things. Also split "stage 3" into two separate stages, keeping the lazy relocations in stage 3, and adding a stage 4 for calling library initialization functions. We also make sure to map the main executable before dealing with any of its dependencies, to ensure that non-PIE executables get loaded at their desired address.
This commit is contained in:
parent
8456dc87d8
commit
79889ef052
3 changed files with 71 additions and 55 deletions
|
@ -154,7 +154,10 @@ void* DynamicLoader::symbol_for_name(const StringView& name)
|
|||
|
||||
RefPtr<DynamicObject> DynamicLoader::map()
|
||||
{
|
||||
VERIFY(!m_dynamic_object);
|
||||
if (m_dynamic_object) {
|
||||
// Already mapped.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!m_valid) {
|
||||
dbgln("DynamicLoader::map failed: image is invalid");
|
||||
|
@ -245,10 +248,14 @@ RefPtr<DynamicObject> DynamicLoader::load_stage_3(unsigned flags, size_t total_t
|
|||
#endif
|
||||
}
|
||||
|
||||
call_object_init_functions();
|
||||
return m_dynamic_object;
|
||||
}
|
||||
|
||||
void DynamicLoader::load_stage_4()
|
||||
{
|
||||
call_object_init_functions();
|
||||
}
|
||||
|
||||
void DynamicLoader::do_lazy_relocations(size_t total_tls_size)
|
||||
{
|
||||
for (const auto& relocation : m_unresolved_relocations) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue