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

Kernel+LibELF: Support initializing values of TLS data

Previously, TLS data was always zero-initialized.

To support initializing the values of TLS data, sys$allocate_tls now
receives a buffer with the desired initial data, and copies it to the
master TLS region of the process.

The DynamicLinker gathers the initial TLS image and passes it to
sys$allocate_tls.

We also now require the size passed to sys$allocate_tls to be
page-aligned, to make things easier. Note that this doesn't waste memory
as the TLS data has to be allocated in separate pages anyway.
This commit is contained in:
Itamar 2021-04-24 11:30:20 +03:00 committed by Andreas Kling
parent db76702d71
commit 6bbd2ebf83
7 changed files with 63 additions and 12 deletions

View file

@ -78,6 +78,7 @@ public:
bool is_dynamic() const { return m_elf_image.is_dynamic(); }
static Optional<DynamicObject::SymbolLookupResult> lookup_symbol(const ELF::DynamicObject::Symbol&);
void copy_initial_tls_data_into(ByteBuffer& buffer, size_t total_tls_size) const;
private:
DynamicLoader(int fd, String filename, void* file_data, size_t file_size);