summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/CMakeLists.txt2
-rw-r--r--Kernel/FileSystem/VirtualFileSystem.cpp2
-rw-r--r--Kernel/Process.h4
-rw-r--r--Kernel/Syscalls/execve.cpp11
-rw-r--r--Kernel/Syscalls/mmap.cpp3
5 files changed, 13 insertions, 9 deletions
diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt
index 9e02c5c0b8..ef5c5585f8 100644
--- a/Kernel/CMakeLists.txt
+++ b/Kernel/CMakeLists.txt
@@ -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
diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp
index 2ba9589dcd..f8dc1698bf 100644
--- a/Kernel/FileSystem/VirtualFileSystem.cpp
+++ b/Kernel/FileSystem/VirtualFileSystem.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("/.."))
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 3e36c61d0e..1ed334eb90 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -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 };
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp
index 14ab994b64..9fbd7c1a97 100644
--- a/Kernel/Syscalls/execve.cpp
+++ b/Kernel/Syscalls/execve.cpp
@@ -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
diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp
index 36aa2a1b67..6607efc41d 100644
--- a/Kernel/Syscalls/mmap.cpp
+++ b/Kernel/Syscalls/mmap.cpp
@@ -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;