ldso: cleanup if loading of 'Shared_object' fails

This can happen, for example, during 'dlopen' if unresolved symbols are
present.

* Unload already loaded shared libraries
* Delete dependencies
* Flush initializer list (ctors)

fixes #3073
This commit is contained in:
Sebastian Sumpf 2018-12-05 17:10:17 +01:00 committed by Norman Feske
parent 7c4986bd83
commit 3347d08b79
2 changed files with 18 additions and 1 deletions

View File

@ -91,5 +91,13 @@ Linker::Root_object::Root_object(Env &env, Allocator &md_alloc,
new (md_alloc) Dependency(env, md_alloc, linker_name(), this, _deps, DONT_KEEP); new (md_alloc) Dependency(env, md_alloc, linker_name(), this, _deps, DONT_KEEP);
/* relocate and call constructors */ /* relocate and call constructors */
Init::list()->initialize(bind, STAGE_SO); try {
Init::list()->initialize(bind, STAGE_SO);
} catch (...) {
Init::list()->flush();
while (Dependency *d = _deps.dequeue())
destroy(_md_alloc, d);
throw;
}
} }

View File

@ -132,6 +132,15 @@ struct Linker::Init : List<Object>
in_progress = false; in_progress = false;
} }
void flush()
{
while (Object *obj = first())
remove(obj);
in_progress = false;
restart = false;
}
}; };
#endif /* _INCLUDE__INIT_H_ */ #endif /* _INCLUDE__INIT_H_ */