1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:07:45 +00:00

LibELF: Move AuxiliaryValue into the ELF namespace

This commit is contained in:
Andreas Kling 2020-12-25 14:48:30 +01:00
parent 6c9a6bea1e
commit 40e9edd798
8 changed files with 40 additions and 39 deletions

View file

@ -534,7 +534,7 @@ private:
ssize_t do_write(FileDescription&, const UserOrKernelBuffer&, size_t);
KResultOr<NonnullRefPtr<FileDescription>> find_elf_interpreter_for_executable(const String& path, char (&first_page)[PAGE_SIZE], int nread, size_t file_size);
Vector<AuxiliaryValue> generate_auxiliary_vector() const;
Vector<ELF::AuxiliaryValue> generate_auxiliary_vector() const;
int alloc_fd(int first_candidate_fd = 0);
void disown_all_shared_buffers();

View file

@ -424,41 +424,41 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
return 0;
}
Vector<AuxiliaryValue> Process::generate_auxiliary_vector() const
Vector<ELF::AuxiliaryValue> Process::generate_auxiliary_vector() const
{
Vector<AuxiliaryValue> auxv;
Vector<ELF::AuxiliaryValue> auxv;
// PHDR/EXECFD
// PH*
auxv.append({ AuxiliaryValue::PageSize, PAGE_SIZE });
auxv.append({ AuxiliaryValue::BaseAddress, (void*)m_load_base });
auxv.append({ ELF::AuxiliaryValue::PageSize, PAGE_SIZE });
auxv.append({ ELF::AuxiliaryValue::BaseAddress, (void*)m_load_base });
auxv.append({ AuxiliaryValue::Entry, (void*)m_entry_eip });
auxv.append({ ELF::AuxiliaryValue::Entry, (void*)m_entry_eip });
// NOTELF
auxv.append({ AuxiliaryValue::Uid, (long)m_uid });
auxv.append({ AuxiliaryValue::EUid, (long)m_euid });
auxv.append({ AuxiliaryValue::Gid, (long)m_gid });
auxv.append({ AuxiliaryValue::EGid, (long)m_egid });
auxv.append({ ELF::AuxiliaryValue::Uid, (long)m_uid });
auxv.append({ ELF::AuxiliaryValue::EUid, (long)m_euid });
auxv.append({ ELF::AuxiliaryValue::Gid, (long)m_gid });
auxv.append({ ELF::AuxiliaryValue::EGid, (long)m_egid });
// FIXME: Don't hard code this? We might support other platforms later.. (e.g. x86_64)
auxv.append({ AuxiliaryValue::Platform, "i386" });
auxv.append({ ELF::AuxiliaryValue::Platform, "i386" });
// FIXME: This is platform specific
auxv.append({ AuxiliaryValue::HwCap, (long)CPUID(1).edx() });
auxv.append({ ELF::AuxiliaryValue::HwCap, (long)CPUID(1).edx() });
auxv.append({ AuxiliaryValue::ClockTick, (long)TimeManagement::the().ticks_per_second() });
auxv.append({ ELF::AuxiliaryValue::ClockTick, (long)TimeManagement::the().ticks_per_second() });
// FIXME: Also take into account things like extended filesystem permissions? That's what linux does...
auxv.append({ AuxiliaryValue::Secure, ((m_uid != m_euid) || (m_gid != m_egid)) ? 1 : 0 });
auxv.append({ ELF::AuxiliaryValue::Secure, ((m_uid != m_euid) || (m_gid != m_egid)) ? 1 : 0 });
char random_bytes[16] {};
get_fast_random_bytes((u8*)random_bytes, sizeof(random_bytes));
auxv.append({ AuxiliaryValue::Random, String(random_bytes, sizeof(random_bytes)) });
auxv.append({ ELF::AuxiliaryValue::Random, String(random_bytes, sizeof(random_bytes)) });
auxv.append({ AuxiliaryValue::ExecFilename, m_executable->absolute_path() });
auxv.append({ ELF::AuxiliaryValue::ExecFilename, m_executable->absolute_path() });
auxv.append({ AuxiliaryValue::ExecFileDescriptor, m_main_program_fd });
auxv.append({ ELF::AuxiliaryValue::ExecFileDescriptor, m_main_program_fd });
auxv.append({ AuxiliaryValue::Null, 0L });
auxv.append({ ELF::AuxiliaryValue::Null, 0L });
return auxv;
}

View file

@ -855,7 +855,7 @@ RegisterState& Thread::get_register_dump_from_stack()
return *(RegisterState*)(kernel_stack_top() - sizeof(RegisterState));
}
KResultOr<u32> Thread::make_userspace_stack_for_main_thread(Vector<String> arguments, Vector<String> environment, Vector<AuxiliaryValue> auxiliary_values)
KResultOr<u32> Thread::make_userspace_stack_for_main_thread(Vector<String> arguments, Vector<String> environment, Vector<ELF::AuxiliaryValue> auxiliary_values)
{
auto* region = m_process->allocate_region(VirtualAddress(), default_userspace_stack_size, "Stack (Main thread)", PROT_READ | PROT_WRITE, false);
if (!region)

View file

@ -975,7 +975,7 @@ public:
void set_default_signal_dispositions();
bool push_value_on_stack(FlatPtr);
KResultOr<u32> make_userspace_stack_for_main_thread(Vector<String> arguments, Vector<String> environment, Vector<AuxiliaryValue>);
KResultOr<u32> make_userspace_stack_for_main_thread(Vector<String> arguments, Vector<String> environment, Vector<ELF::AuxiliaryValue>);
KResult make_thread_specific_region(Badge<Process>);