mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 12:07:45 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -35,9 +35,9 @@
|
|||
|
||||
namespace ELF {
|
||||
|
||||
static HashMap<String, NonnullRefPtr<ELF::DynamicLoader>> s_loaders;
|
||||
static String s_main_program_path;
|
||||
static OrderedHashMap<String, NonnullRefPtr<ELF::DynamicObject>> s_global_objects;
|
||||
static HashMap<DeprecatedString, NonnullRefPtr<ELF::DynamicLoader>> s_loaders;
|
||||
static DeprecatedString s_main_program_path;
|
||||
static OrderedHashMap<DeprecatedString, NonnullRefPtr<ELF::DynamicObject>> s_global_objects;
|
||||
|
||||
using EntryPointFunction = int (*)(int, char**, char**);
|
||||
using LibCExitFunction = void (*)(int);
|
||||
|
@ -52,13 +52,13 @@ static size_t s_allocated_tls_block_size = 0;
|
|||
static char** s_envp = nullptr;
|
||||
static LibCExitFunction s_libc_exit = nullptr;
|
||||
static __pthread_mutex_t s_loader_lock = __PTHREAD_MUTEX_INITIALIZER;
|
||||
static String s_cwd;
|
||||
static DeprecatedString s_cwd;
|
||||
|
||||
static bool s_allowed_to_check_environment_variables { false };
|
||||
static bool s_do_breakpoint_trap_before_entry { false };
|
||||
static StringView s_ld_library_path;
|
||||
static StringView s_main_program_pledge_promises;
|
||||
static String s_loader_pledge_promises;
|
||||
static DeprecatedString s_loader_pledge_promises;
|
||||
|
||||
static Result<void, DlErrorMessage> __dlclose(void* handle);
|
||||
static Result<void*, DlErrorMessage> __dlopen(char const* filename, int flags);
|
||||
|
@ -84,7 +84,7 @@ Optional<DynamicObject::SymbolLookupResult> DynamicLinker::lookup_global_symbol(
|
|||
return weak_result;
|
||||
}
|
||||
|
||||
static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> map_library(String const& filepath, int fd)
|
||||
static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> map_library(DeprecatedString const& filepath, int fd)
|
||||
{
|
||||
VERIFY(filepath.starts_with('/'));
|
||||
|
||||
|
@ -104,7 +104,7 @@ static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> map_library(String c
|
|||
return loader;
|
||||
}
|
||||
|
||||
static Optional<String> resolve_library(String const& name, DynamicObject const& parent_object)
|
||||
static Optional<DeprecatedString> 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.
|
||||
|
@ -129,7 +129,7 @@ static Optional<String> resolve_library(String const& name, DynamicObject const&
|
|||
|
||||
for (auto const& search_path : search_paths) {
|
||||
LexicalPath library_path(search_path.replace("$ORIGIN"sv, LexicalPath::dirname(parent_object.filepath()), ReplaceMode::FirstOnly));
|
||||
String library_name = library_path.append(name).string();
|
||||
DeprecatedString library_name = library_path.append(name).string();
|
||||
|
||||
if (access(library_name.characters(), F_OK) == 0)
|
||||
return library_name;
|
||||
|
@ -138,24 +138,24 @@ static Optional<String> resolve_library(String const& name, DynamicObject const&
|
|||
return {};
|
||||
}
|
||||
|
||||
static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> map_library(String const& path)
|
||||
static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> map_library(DeprecatedString const& path)
|
||||
{
|
||||
VERIFY(path.starts_with('/'));
|
||||
|
||||
int fd = open(path.characters(), O_RDONLY);
|
||||
if (fd < 0)
|
||||
return DlErrorMessage { String::formatted("Could not open shared library '{}': {}", path, strerror(errno)) };
|
||||
return DlErrorMessage { DeprecatedString::formatted("Could not open shared library '{}': {}", path, strerror(errno)) };
|
||||
|
||||
return map_library(path, fd);
|
||||
}
|
||||
|
||||
static Vector<String> get_dependencies(String const& path)
|
||||
static Vector<DeprecatedString> get_dependencies(DeprecatedString const& path)
|
||||
{
|
||||
VERIFY(path.starts_with('/'));
|
||||
|
||||
auto name = LexicalPath::basename(path);
|
||||
auto lib = s_loaders.get(path).value();
|
||||
Vector<String> dependencies;
|
||||
Vector<DeprecatedString> dependencies;
|
||||
|
||||
lib->for_each_needed_library([&dependencies, &name](auto needed_name) {
|
||||
if (name == needed_name)
|
||||
|
@ -165,7 +165,7 @@ static Vector<String> get_dependencies(String const& path)
|
|||
return dependencies;
|
||||
}
|
||||
|
||||
static Result<void, DlErrorMessage> map_dependencies(String const& path)
|
||||
static Result<void, DlErrorMessage> map_dependencies(DeprecatedString const& path)
|
||||
{
|
||||
VERIFY(path.starts_with('/'));
|
||||
|
||||
|
@ -179,7 +179,7 @@ static Result<void, DlErrorMessage> map_dependencies(String const& path)
|
|||
auto dependency_path = resolve_library(needed_name, parent_object);
|
||||
|
||||
if (!dependency_path.has_value())
|
||||
return DlErrorMessage { String::formatted("Could not find required shared library: {}", needed_name) };
|
||||
return DlErrorMessage { DeprecatedString::formatted("Could not find required shared library: {}", needed_name) };
|
||||
|
||||
if (!s_loaders.contains(dependency_path.value()) && !s_global_objects.contains(dependency_path.value())) {
|
||||
auto loader = TRY(map_library(dependency_path.value()));
|
||||
|
@ -303,7 +303,7 @@ static void initialize_libc(DynamicObject& libc)
|
|||
}
|
||||
|
||||
template<typename Callback>
|
||||
static void for_each_unfinished_dependency_of(String const& path, HashTable<String>& seen_names, Callback callback)
|
||||
static void for_each_unfinished_dependency_of(DeprecatedString const& path, HashTable<DeprecatedString>& seen_names, Callback callback)
|
||||
{
|
||||
VERIFY(path.starts_with('/'));
|
||||
|
||||
|
@ -338,11 +338,11 @@ static void for_each_unfinished_dependency_of(String const& path, HashTable<Stri
|
|||
callback(*s_loaders.get(path).value());
|
||||
}
|
||||
|
||||
static NonnullRefPtrVector<DynamicLoader> collect_loaders_for_library(String const& path)
|
||||
static NonnullRefPtrVector<DynamicLoader> collect_loaders_for_library(DeprecatedString const& path)
|
||||
{
|
||||
VERIFY(path.starts_with('/'));
|
||||
|
||||
HashTable<String> seen_names;
|
||||
HashTable<DeprecatedString> seen_names;
|
||||
NonnullRefPtrVector<DynamicLoader> loaders;
|
||||
for_each_unfinished_dependency_of(path, seen_names, [&](auto& loader) {
|
||||
loaders.append(loader);
|
||||
|
@ -357,7 +357,7 @@ static void drop_loader_promise(StringView promise_to_drop)
|
|||
|
||||
s_loader_pledge_promises = s_loader_pledge_promises.replace(promise_to_drop, ""sv, ReplaceMode::All);
|
||||
|
||||
auto extended_promises = String::formatted("{} {}", s_main_program_pledge_promises, s_loader_pledge_promises);
|
||||
auto extended_promises = DeprecatedString::formatted("{} {}", s_main_program_pledge_promises, s_loader_pledge_promises);
|
||||
Syscall::SC_pledge_params params {
|
||||
{ extended_promises.characters(), extended_promises.length() },
|
||||
{ nullptr, 0 },
|
||||
|
@ -369,7 +369,7 @@ static void drop_loader_promise(StringView promise_to_drop)
|
|||
}
|
||||
}
|
||||
|
||||
static Result<void, DlErrorMessage> link_main_library(String const& path, int flags)
|
||||
static Result<void, DlErrorMessage> link_main_library(DeprecatedString const& path, int flags)
|
||||
{
|
||||
VERIFY(path.starts_with('/'));
|
||||
|
||||
|
@ -384,7 +384,7 @@ static Result<void, DlErrorMessage> link_main_library(String const& path, int fl
|
|||
for (auto& loader : loaders) {
|
||||
bool success = loader.link(flags);
|
||||
if (!success) {
|
||||
return DlErrorMessage { String::formatted("Failed to link library {}", loader.filepath()) };
|
||||
return DlErrorMessage { DeprecatedString::formatted("Failed to link library {}", loader.filepath()) };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -479,7 +479,7 @@ static Result<void*, DlErrorMessage> __dlopen(char const* filename, int flags)
|
|||
auto library_path = (filename ? resolve_library(filename, parent_object) : s_main_program_path);
|
||||
|
||||
if (!library_path.has_value())
|
||||
return DlErrorMessage { String::formatted("Could not find required shared library: {}", filename) };
|
||||
return DlErrorMessage { DeprecatedString::formatted("Could not find required shared library: {}", filename) };
|
||||
|
||||
auto existing_elf_object = s_global_objects.get(library_path.value());
|
||||
if (existing_elf_object.has_value()) {
|
||||
|
@ -528,7 +528,7 @@ static Result<void*, DlErrorMessage> __dlsym(void* handle, char const* symbol_na
|
|||
}
|
||||
|
||||
if (!symbol.has_value())
|
||||
return DlErrorMessage { String::formatted("Symbol {} not found", symbol_name_view) };
|
||||
return DlErrorMessage { DeprecatedString::formatted("Symbol {} not found", symbol_name_view) };
|
||||
|
||||
if (symbol.value().type == STT_GNU_IFUNC)
|
||||
return (void*)reinterpret_cast<DynamicObject::IfuncResolver>(symbol.value().address.as_ptr())();
|
||||
|
@ -602,7 +602,7 @@ static void read_environment_variables()
|
|||
}
|
||||
}
|
||||
|
||||
void ELF::DynamicLinker::linker_main(String&& main_program_path, int main_program_fd, bool is_secure, int argc, char** argv, char** envp)
|
||||
void ELF::DynamicLinker::linker_main(DeprecatedString&& main_program_path, int main_program_fd, bool is_secure, int argc, char** argv, char** envp)
|
||||
{
|
||||
VERIFY(main_program_path.starts_with('/'));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue