Kernel/LibC/DynamicLoader: Implement thread local storage

For some reason this does not work on 32 bit version, so it is disabled
on that platform. I'll have to look into it later to find the bug :)
This commit is contained in:
2025-04-15 23:33:39 +03:00
parent 08f5833ca8
commit ac90800c3c
10 changed files with 447 additions and 15 deletions

View File

@@ -8,8 +8,15 @@ namespace Kernel::ELF
struct LoadResult
{
bool has_interpreter;
struct TLS
{
vaddr_t addr;
size_t size;
};
bool open_execfd;
vaddr_t entry_point;
BAN::Optional<TLS> master_tls;
BAN::Vector<BAN::UniqPtr<MemoryRegion>> regions;
};

View File

@@ -6,6 +6,7 @@
#include <BAN/StringView.h>
#include <BAN/Vector.h>
#include <kernel/Credentials.h>
#include <kernel/ELF.h>
#include <kernel/FS/Inode.h>
#include <kernel/Lock/Mutex.h>
#include <kernel/Memory/Heap.h>
@@ -219,6 +220,13 @@ namespace Kernel
Process(const Credentials&, pid_t pid, pid_t parent, pid_t sid, pid_t pgrp);
static Process* create_process(const Credentials&, pid_t parent, pid_t sid = 0, pid_t pgrp = 0);
struct TLSResult
{
BAN::UniqPtr<MemoryRegion> region;
vaddr_t addr;
};
static BAN::ErrorOr<TLSResult> initialize_thread_local_storage(PageTable&, ELF::LoadResult::TLS master_tls);
struct FileParent
{
VirtualFileSystem::File parent;