1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +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

@ -389,7 +389,7 @@ public:
KResultOr<int> sys$recvfd(int sockfd, int options);
KResultOr<long> sys$sysconf(int name);
KResultOr<int> sys$disown(ProcessID);
KResultOr<FlatPtr> sys$allocate_tls(size_t);
KResultOr<FlatPtr> sys$allocate_tls(Userspace<const char*> initial_data, size_t);
KResultOr<int> sys$prctl(int option, FlatPtr arg1, FlatPtr arg2);
KResultOr<int> sys$set_coredump_metadata(Userspace<const Syscall::SC_set_coredump_metadata_params*>);
KResultOr<int> sys$anon_create(size_t, int options);