mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:37:35 +00:00
LibELF: Use StringView to carry temporary strings in auxiliary vector
Let's not force clients to provide a String.
This commit is contained in:
parent
cae20d2aa9
commit
226383f45b
3 changed files with 7 additions and 7 deletions
|
@ -40,7 +40,7 @@ struct LoadResult {
|
||||||
WeakPtr<Memory::Region> stack_region;
|
WeakPtr<Memory::Region> stack_region;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Vector<ELF::AuxiliaryValue> generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, UserID uid, UserID euid, GroupID gid, GroupID egid, String executable_path, Optional<Process::ScopedDescriptionAllocation> const& main_program_fd_allocation);
|
static Vector<ELF::AuxiliaryValue> generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, UserID uid, UserID euid, GroupID gid, GroupID egid, StringView executable_path, Optional<Process::ScopedDescriptionAllocation> const& main_program_fd_allocation);
|
||||||
|
|
||||||
static bool validate_stack_size(const Vector<String>& arguments, const Vector<String>& environment)
|
static bool validate_stack_size(const Vector<String>& arguments, const Vector<String>& environment)
|
||||||
{
|
{
|
||||||
|
@ -90,10 +90,10 @@ static KResultOr<FlatPtr> make_userspace_context_for_main_thread([[maybe_unused]
|
||||||
VERIFY(result.is_success());
|
VERIFY(result.is_success());
|
||||||
};
|
};
|
||||||
|
|
||||||
auto push_string_on_new_stack = [&new_sp](const String& string) {
|
auto push_string_on_new_stack = [&new_sp](StringView string) {
|
||||||
new_sp -= round_up_to_power_of_two(string.length() + 1, sizeof(FlatPtr));
|
new_sp -= round_up_to_power_of_two(string.length() + 1, sizeof(FlatPtr));
|
||||||
Userspace<FlatPtr*> stack_ptr = new_sp;
|
Userspace<FlatPtr*> stack_ptr = new_sp;
|
||||||
auto result = copy_to_user(stack_ptr, string.characters(), string.length() + 1);
|
auto result = copy_to_user(stack_ptr, string.characters_without_null_termination(), string.length() + 1);
|
||||||
VERIFY(result.is_success());
|
VERIFY(result.is_success());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -633,7 +633,7 @@ KResult Process::do_exec(NonnullRefPtr<FileDescription> main_program_description
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector<ELF::AuxiliaryValue> generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, UserID uid, UserID euid, GroupID gid, GroupID egid, String executable_path, Optional<Process::ScopedDescriptionAllocation> const& main_program_fd_allocation)
|
static Vector<ELF::AuxiliaryValue> generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, UserID uid, UserID euid, GroupID gid, GroupID egid, StringView executable_path, Optional<Process::ScopedDescriptionAllocation> const& main_program_fd_allocation)
|
||||||
{
|
{
|
||||||
Vector<ELF::AuxiliaryValue> auxv;
|
Vector<ELF::AuxiliaryValue> auxv;
|
||||||
// PHDR/EXECFD
|
// PHDR/EXECFD
|
||||||
|
|
|
@ -115,7 +115,7 @@ void Emulator::setup_stack(Vector<ELF::AuxiliaryValue> aux_vector)
|
||||||
|
|
||||||
for (auto& auxv : aux_vector) {
|
for (auto& auxv : aux_vector) {
|
||||||
if (!auxv.optional_string.is_empty()) {
|
if (!auxv.optional_string.is_empty()) {
|
||||||
m_cpu.push_string(auxv.optional_string.characters());
|
m_cpu.push_string(auxv.optional_string);
|
||||||
auxv.auxv.a_un.a_ptr = (void*)m_cpu.esp().value();
|
auxv.auxv.a_un.a_ptr = (void*)m_cpu.esp().value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ struct AuxiliaryValue {
|
||||||
auxv.a_type = type;
|
auxv.a_type = type;
|
||||||
auxv.a_un.a_ptr = (void*)ptr;
|
auxv.a_un.a_ptr = (void*)ptr;
|
||||||
}
|
}
|
||||||
AuxiliaryValue(Type type, String string)
|
AuxiliaryValue(Type type, StringView string)
|
||||||
{
|
{
|
||||||
auxv.a_type = type;
|
auxv.a_type = type;
|
||||||
auxv.a_un.a_ptr = nullptr;
|
auxv.a_un.a_ptr = nullptr;
|
||||||
|
@ -97,7 +97,7 @@ struct AuxiliaryValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
auxv_t auxv {};
|
auxv_t auxv {};
|
||||||
String optional_string;
|
StringView optional_string;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue