mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:27:35 +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:
parent
db76702d71
commit
6bbd2ebf83
7 changed files with 63 additions and 12 deletions
|
@ -73,9 +73,9 @@ int madvise(void* address, size_t size, int advice)
|
|||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
void* allocate_tls(size_t size)
|
||||
void* allocate_tls(const char* initial_data, size_t size)
|
||||
{
|
||||
ptrdiff_t rc = syscall(SC_allocate_tls, size);
|
||||
ptrdiff_t rc = syscall(SC_allocate_tls, initial_data, size);
|
||||
if (rc < 0 && -rc < EMAXERRNO) {
|
||||
errno = -rc;
|
||||
return MAP_FAILED;
|
||||
|
|
|
@ -40,6 +40,6 @@ int munmap(void*, size_t);
|
|||
int mprotect(void*, size_t, int prot);
|
||||
int set_mmap_name(void*, size_t, const char*);
|
||||
int madvise(void*, size_t, int advice);
|
||||
void* allocate_tls(size_t);
|
||||
void* allocate_tls(const char* initial_data, size_t);
|
||||
|
||||
__END_DECLS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue