summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-12-18 16:41:09 +0200
committerAndrew Kaster <andrewdkaster@gmail.com>2022-12-31 05:06:39 -0700
commitefec3448038fccd1de7fd56c3b673f1e62e282df (patch)
treefd7595e0da9f33d0c65fa197271f0c99f83036b3 /Userland/Libraries
parentab8522aa17be787b857c890d871b4bfc267e6bd0 (diff)
downloadserenity-efec3448038fccd1de7fd56c3b673f1e62e282df.zip
LibELF: Export static resolve_library method of the DynamicLinker code
It will be used in the following commit to introduce a new utility to use this method.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibELF/DynamicLinker.cpp8
-rw-r--r--Userland/Libraries/LibELF/DynamicLinker.h2
2 files changed, 6 insertions, 4 deletions
diff --git a/Userland/Libraries/LibELF/DynamicLinker.cpp b/Userland/Libraries/LibELF/DynamicLinker.cpp
index 65f1ee988c..6ba24599a2 100644
--- a/Userland/Libraries/LibELF/DynamicLinker.cpp
+++ b/Userland/Libraries/LibELF/DynamicLinker.cpp
@@ -105,7 +105,7 @@ static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> map_library(Deprecat
return loader;
}
-static Optional<DeprecatedString> resolve_library(DeprecatedString const& name, DynamicObject const& parent_object)
+Optional<DeprecatedString> DynamicLinker::resolve_library(DeprecatedString const& name, DynamicObject const& parent_object)
{
// Absolute and relative (to the current working directory) paths are already considered resolved.
// However, ensure that the returned path is absolute and canonical, so pass it through LexicalPath.
@@ -185,7 +185,7 @@ static Result<void, DlErrorMessage> map_dependencies(DeprecatedString const& pat
for (auto const& needed_name : get_dependencies(path)) {
dbgln_if(DYNAMIC_LOAD_DEBUG, "needed library: {}", needed_name.characters());
- auto dependency_path = resolve_library(needed_name, parent_object);
+ auto dependency_path = DynamicLinker::resolve_library(needed_name, parent_object);
if (!dependency_path.has_value())
return DlErrorMessage { DeprecatedString::formatted("Could not find required shared library: {}", needed_name) };
@@ -340,7 +340,7 @@ static void for_each_unfinished_dependency_of(DeprecatedString const& path, Hash
seen_names.set(path);
for (auto const& needed_name : get_dependencies(path)) {
- auto dependency_path = *resolve_library(needed_name, loader.value()->dynamic_object());
+ auto dependency_path = *DynamicLinker::resolve_library(needed_name, loader.value()->dynamic_object());
for_each_unfinished_dependency_of(dependency_path, seen_names, callback);
}
@@ -493,7 +493,7 @@ static Result<void*, DlErrorMessage> __dlopen(char const* filename, int flags)
auto const& parent_object = **s_global_objects.get(s_main_program_path);
- auto library_path = (filename ? resolve_library(filename, parent_object) : s_main_program_path);
+ auto library_path = (filename ? DynamicLinker::resolve_library(filename, parent_object) : s_main_program_path);
if (!library_path.has_value())
return DlErrorMessage { DeprecatedString::formatted("Could not find required shared library: {}", filename) };
diff --git a/Userland/Libraries/LibELF/DynamicLinker.h b/Userland/Libraries/LibELF/DynamicLinker.h
index df17bae74a..4cfa7a6419 100644
--- a/Userland/Libraries/LibELF/DynamicLinker.h
+++ b/Userland/Libraries/LibELF/DynamicLinker.h
@@ -17,6 +17,8 @@ public:
static Optional<DynamicObject::SymbolLookupResult> lookup_global_symbol(StringView symbol);
[[noreturn]] static void linker_main(DeprecatedString&& main_program_path, int fd, bool is_secure, int argc, char** argv, char** envp);
+ static Optional<DeprecatedString> resolve_library(DeprecatedString const& name, DynamicObject const& parent_object);
+
private:
DynamicLinker() = delete;
~DynamicLinker() = delete;