mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:07:45 +00:00
Loader: Stabilize loader & Use shared libraries everywhere :^)
The dynamic loader is now stable enough to be used everywhere in the system - so this commit does just that. No More .a Files, Long Live .so's!
This commit is contained in:
parent
c917fcbac4
commit
efe4da57df
28 changed files with 401 additions and 173 deletions
|
@ -3,6 +3,8 @@ set(KERNEL_HEAP_SOURCES
|
|||
Heap/kmalloc.cpp
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_STATIC}")
|
||||
|
||||
set(KERNEL_SOURCES
|
||||
ACPI/DynamicParser.cpp
|
||||
ACPI/Initialize.cpp
|
||||
|
|
|
@ -841,6 +841,8 @@ KResult VFS::validate_path_against_process_veil(StringView path, int options)
|
|||
{
|
||||
if (Process::current()->veil_state() == VeilState::None)
|
||||
return KSuccess;
|
||||
if (path == "/usr/lib/Loader.so")
|
||||
return KSuccess;
|
||||
|
||||
// FIXME: Figure out a nicer way to do this.
|
||||
if (String(path).contains("/.."))
|
||||
|
|
|
@ -423,7 +423,7 @@ public:
|
|||
int exec(String path, Vector<String> arguments, Vector<String> environment, int recusion_depth = 0);
|
||||
|
||||
struct LoadResult {
|
||||
FlatPtr load_offset { 0 };
|
||||
FlatPtr load_base { 0 };
|
||||
FlatPtr entry_eip { 0 };
|
||||
size_t size { 0 };
|
||||
FlatPtr program_headers { 0 };
|
||||
|
@ -581,7 +581,7 @@ private:
|
|||
gid_t m_sgid { 0 };
|
||||
|
||||
ThreadID m_exec_tid { 0 };
|
||||
FlatPtr m_load_offset { 0U };
|
||||
FlatPtr m_load_base { 0U };
|
||||
FlatPtr m_entry_eip { 0U };
|
||||
int m_main_program_fd { -1 };
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ KResultOr<Process::LoadResult> Process::load_elf_object(FileDescription& object_
|
|||
size_t master_tls_size = 0;
|
||||
size_t master_tls_alignment = 0;
|
||||
m_entry_eip = 0;
|
||||
FlatPtr load_base_address = 0;
|
||||
|
||||
MM.enter_process_paging_scope(*this);
|
||||
String object_name = LexicalPath(object_description.absolute_path()).basename();
|
||||
|
@ -96,6 +97,8 @@ KResultOr<Process::LoadResult> Process::load_elf_object(FileDescription& object_
|
|||
prot |= PROT_EXEC;
|
||||
if (auto* region = allocate_region_with_vmobject(vaddr.offset(load_offset), size, *vmobject, offset_in_image, String(name), prot)) {
|
||||
region->set_shared(true);
|
||||
if (offset_in_image == 0)
|
||||
load_base_address = (FlatPtr)region->vaddr().as_ptr();
|
||||
return region->vaddr().as_ptr();
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -137,7 +140,7 @@ KResultOr<Process::LoadResult> Process::load_elf_object(FileDescription& object_
|
|||
// NOTE: At this point, we've committed to the new executable.
|
||||
|
||||
return LoadResult {
|
||||
load_offset,
|
||||
load_base_address,
|
||||
loader->entry().offset(load_offset).get(),
|
||||
(size_t)loader_metadata.size,
|
||||
VirtualAddress(loader->image().program_header_table_offset()).offset(load_offset).get(),
|
||||
|
@ -175,7 +178,7 @@ int Process::load(NonnullRefPtr<FileDescription> main_program_description, RefPt
|
|||
if (result.is_error())
|
||||
return result.error();
|
||||
|
||||
m_load_offset = result.value().load_offset;
|
||||
m_load_base = result.value().load_base;
|
||||
m_entry_eip = result.value().entry_eip;
|
||||
m_master_tls_region = result.value().tls_region;
|
||||
m_master_tls_size = result.value().tls_size;
|
||||
|
@ -192,7 +195,7 @@ int Process::load(NonnullRefPtr<FileDescription> main_program_description, RefPt
|
|||
if (interpreter_load_result.is_error())
|
||||
return interpreter_load_result.error();
|
||||
|
||||
m_load_offset = interpreter_load_result.value().load_offset;
|
||||
m_load_base = interpreter_load_result.value().load_base;
|
||||
m_entry_eip = interpreter_load_result.value().entry_eip;
|
||||
|
||||
// TLS allocation will be done in userspace by the loader
|
||||
|
@ -357,7 +360,7 @@ Vector<AuxiliaryValue> Process::generate_auxiliary_vector() const
|
|||
// PHDR/EXECFD
|
||||
// PH*
|
||||
auxv.append({ AuxiliaryValue::PageSize, PAGE_SIZE });
|
||||
auxv.append({ AuxiliaryValue::BaseAddress, (void*)m_load_offset });
|
||||
auxv.append({ AuxiliaryValue::BaseAddress, (void*)m_load_base });
|
||||
|
||||
auxv.append({ AuxiliaryValue::Entry, (void*)m_entry_eip });
|
||||
// NOTELF
|
||||
|
|
|
@ -422,8 +422,6 @@ void* Process::sys$allocate_tls(size_t size)
|
|||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
|
||||
dbg() << "allocate TLS: " << size;
|
||||
|
||||
if (!size)
|
||||
return (void*)-EINVAL;
|
||||
|
||||
|
@ -445,7 +443,6 @@ void* Process::sys$allocate_tls(size_t size)
|
|||
return (void*)-EFAULT;
|
||||
|
||||
m_master_tls_region = tls_region->make_weak_ptr();
|
||||
dbg() << "master_tls_region: " << m_master_tls_region->vaddr();
|
||||
m_master_tls_size = size;
|
||||
m_master_tls_alignment = PAGE_SIZE;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue