diff options
author | Tim Schumacher <timschumi@gmx.de> | 2022-12-26 17:35:08 +0100 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-12-31 04:16:57 -0700 |
commit | 83f6d5b26a61e0e40ebc7bcbcdb40a2dcc71c6ae (patch) | |
tree | 8c2240782c4caf9b784ba634f5d5308aea044441 /Userland/Libraries/LibELF | |
parent | 1011067a60d6d6284c5ffc104d5a3c3dcc7f9900 (diff) | |
download | serenity-83f6d5b26a61e0e40ebc7bcbcdb40a2dcc71c6ae.zip |
LibELF: Warn if resolving a library resulted in a relative path
Diffstat (limited to 'Userland/Libraries/LibELF')
-rw-r--r-- | Userland/Libraries/LibELF/DynamicLinker.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Userland/Libraries/LibELF/DynamicLinker.cpp b/Userland/Libraries/LibELF/DynamicLinker.cpp index b0752fc0f7..65f1ee988c 100644 --- a/Userland/Libraries/LibELF/DynamicLinker.cpp +++ b/Userland/Libraries/LibELF/DynamicLinker.cpp @@ -132,8 +132,16 @@ static Optional<DeprecatedString> resolve_library(DeprecatedString const& name, LexicalPath library_path(search_path.replace("$ORIGIN"sv, LexicalPath::dirname(parent_object.filepath()), ReplaceMode::FirstOnly)); DeprecatedString library_name = library_path.append(name).string(); - if (access(library_name.characters(), F_OK) == 0) + if (access(library_name.characters(), F_OK) == 0) { + if (!library_name.starts_with('/')) { + // FIXME: Non-absolute paths should resolve from the current working directory. However, + // since that's almost never the effect that is actually desired, let's print + // a warning and only implement it once something actually needs that behavior. + dbgln("\033[33mWarning:\033[0m Resolving library '{}' resulted in non-absolute path '{}'. Check your binary for relative RPATHs and RUNPATHs.", name, library_name); + } + return library_name; + } } return {}; |