]> git.ipfire.org Git - thirdparty/glibc.git/commit
Consolidate TLS block allocation for static binaries with ld.so
authorFlorian Weimer <fweimer@redhat.com>
Thu, 16 Jan 2025 19:02:42 +0000 (20:02 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 16 Jan 2025 19:02:42 +0000 (20:02 +0100)
commitcbd9fd236981717d3d4ee942986ea912e9707c32
treef6ea10053a17a49c2dcf73c4b23396e960186816
parent7f784ffc173b5a2166ff846fd003a2264d614456
Consolidate TLS block allocation for static binaries with ld.so

Use the same code to compute the TLS block size and its alignment.
The code in elf/dl-tls.c is linked in anyway for all binaries
due to the reference to _dl_tls_static_surplus_init.

It is not possible to call _dl_allocate_tls_storage directly
because malloc is not available in the static case.  (The
dynamic linker uses the minimal malloc at this stage.)  Therefore,
split _dl_tls_block_size_with_pre and _dl_tls_block_align from
_dl_allocate_tls_storage, and call those new functions from
__libc_setup_tls.

This fixes extra TLS allocation for the static case, and apparently
some pre-existing bugs as well (the independent recomputation of
TLS block sizes in init_static_tls looks rather suspect).

Fixes commit 0e411c5d3098982d67cd2d7a233eaa6c977a1869 ("Add generic
'extra TLS'").
csu/libc-tls.c
elf/dl-tls.c
elf/dl-tls_block_align.h [new file with mode: 0644]