LibELF: Warn if resolving a library resulted in a relative path
This commit is contained in:
parent
1011067a60
commit
83f6d5b26a
Notes:
sideshowbarker
2024-07-17 02:23:54 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/83f6d5b26a Pull-request: https://github.com/SerenityOS/serenity/pull/16675 Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 9 additions and 1 deletions
|
@ -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 {};
|
||||
|
|
Loading…
Add table
Reference in a new issue