CVS commit: [netbsd-11] src/libexec/ld.elf_so

"Martin Husemann" <[email protected]> Sun, 2 Aug 2026 13:19:34 +0000
Newsgroups gmane.os.netbsd.devel.cvs
Message-ID <[email protected]>
Module Name:	src
Committed By:	martin
Date:		Sun Aug  2 13:19:34 UTC 2026

Modified Files:
	src/libexec/ld.elf_so [netbsd-11]: tls.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #395):

	libexec/ld.elf_so/tls.c: revision 1.32
	libexec/ld.elf_so/tls.c: revision 1.33
	libexec/ld.elf_so/tls.c: revision 1.34

ld.elf_so: Fix assertions for TLS variant I without _lwp_settcb.

In variant I, the TLS address is always

        (uint8_t *)tcb + sizeof(struct tls_tcb) + obj->tlsoffset.

With _lwp_settcb, (uint8_t *)tcb + sizeof(struct tls_tcb) is aligned,
whereas without it, (uint8_t *)tcb is aligned.  Consequently, with
_lwp_settcb, obj->tlsoffset must also be aligned, whereas without it,
obj->tlsoffset + sizeof(struct tls_tcb) must be aligned -- and hence,
without _lwp_settcb, obj->tlsoffset must be congruent to
-sizeof(struct tls_tcb) modulo the alignment.

No functional change intended for non-DEBUG builds: assertion changes
only here.

PR bin/60469: bin/60469: assertion "ALIGNED_P(q, obj->tlsalign)"
failed: file "/usr/src/libexec/ld.elf_so/tls.c", line 333

ld.elf_so: Sprinkle assertions in _rtld_tls_module_allocate.

No functional change intended for non-DEBUG builds: assertion changes
only here.

PR bin/60469: bin/60469: assertion "ALIGNED_P(q, obj->tlsalign)"
failed: file "/usr/src/libexec/ld.elf_so/tls.c", line 333

ld.elf_so: Prune some dead TLS variant branches.
__lwp_settcb / __lwp_gettcb_fast are used only with TLS variant I,
never with TLS variant II.

So say `#ifdef __HAVE_TLS_VARIANT_II' instead of `#ifndef
__HAVE_TLS_VARIANT_I' to make it clearer, and prune all the
__HAVE___LWP_SETTCB / __HAVE___LWP_GETTCB_FAST branches under it
because they're unreachable.

No functional change intended: all the deleted code should be dead.

PR bin/60469: bin/60469: assertion "ALIGNED_P(q, obj->tlsalign)"
failed: file "/usr/src/libexec/ld.elf_so/tls.c", line 333


To generate a diff of this commit:
cvs rdiff -u -r1.23.2.3 -r1.23.2.4 src/libexec/ld.elf_so/tls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.