freebsd-src/lib/libc
Jessica Clarke c668cd775b libc/riscv: Fix initial exec TLS mode for dynamically loaded shared objects
The offset here is relative to the TCB, not whatever the thread pointer
points to, so as with powerpc and powerpc64 we need to account for that.
However, rather than using hard-coded offsets as they did, due to
predating machine/tls.h, we can just re-use _tcb_get().

Note that if libthr is used, and its initialiser has been called, it
will take a different path that uses _get_static_tls_base, which works
just fine on riscv (adding the offset to thr->tcb). This only affects
programs that aren't linked against libthr (or that are but manage to
dlopen before the initialiser is called, if that's even possible).

In future this code should be made MI by just reusing _tcb_get() and
checking the TLS variant (since the offset here is positive even for
variant II, where it should be subtracted), but this is a targeted fix
that makes it clear what's changing.

Reviewed by:	kib
Fixes:		5d00c5a657 ("Fix initial exec TLS mode for dynamically loaded shared objects.")
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D50564

(cherry picked from commit 0e3dbc64d9)
2025-12-15 17:56:36 +00:00
..
aarch64 Remove "All Rights Reserved" from Foundation copyrights 2023-09-25 09:49:25 -04:00
amd64 Remove $FreeBSD$: one-line sh pattern 2023-08-23 11:43:30 -06:00
arm gdtoa: Regenerate configuration headers for 32-bit arm. 2024-07-31 14:25:35 +02:00
capability Remove "All Rights Reserved" from Foundation copyrights 2023-09-25 09:49:25 -04:00
compat-43 Remove $FreeBSD$: one-line nroff pattern 2023-08-23 11:43:32 -06:00
csu libc/csu: Unify INIT_RELOCS across architectures 2025-12-15 17:56:35 +00:00
db Remove $FreeBSD$: one-line ps tag 2023-08-23 11:43:34 -06:00
gdtoa Remove "All Rights Reserved" from Foundation copyrights 2023-09-25 09:49:25 -04:00
gen libc: Fix dl_iterate_phdr's dlpi_tls_data for PowerPC and RISC-V 2025-12-15 17:56:36 +00:00
gmon Remove $FreeBSD$: one-line nroff pattern 2023-08-23 11:43:32 -06:00
i386 Remove $FreeBSD$: one-line nroff pattern 2023-08-23 11:43:32 -06:00
iconv libc: Fix parsing of hexadecimal numbers in strtol() family. 2023-09-07 11:00:30 +02:00
include libc_private.h: use private namespace name for size_t 2024-04-30 04:15:47 +03:00
inet libc: Import OpenBSD's inet_net_{ntop,pton} 2025-10-25 05:41:37 +01:00
isc Remove $FreeBSD$: one-line sh pattern 2023-08-23 11:43:30 -06:00
locale Remove "All Rights Reserved" from Foundation copyrights 2023-09-25 09:49:25 -04:00
md Remove $FreeBSD$: one-line sh pattern 2023-08-23 11:43:30 -06:00
mips Remove $FreeBSD$: one-line sh pattern 2023-08-23 11:43:30 -06:00
nameser Remove $FreeBSD$: one-line sh pattern 2023-08-23 11:43:30 -06:00
net link_addr: be more strict about address formats 2025-05-21 00:17:06 +01:00
nls Remove $FreeBSD$: one-line catalog 2023-08-23 11:43:33 -06:00
posix1e libc: correct some memory leaks in acl_to_text(3) and acl_to_text_np(3) 2023-12-21 17:20:39 +02:00
powerpc Purge more stray embedded $FreeBSD$ strings 2023-10-24 11:13:18 -07:00
powerpc64 Purge more stray embedded $FreeBSD$ strings 2023-10-24 11:13:18 -07:00
powerpcspe Remove $FreeBSD$: one-line sh pattern 2023-08-23 11:43:30 -06:00
quad Remove $FreeBSD$: one-line sh pattern 2023-08-23 11:43:30 -06:00
regex regex: mixed sets are misidentified as singletons 2024-09-25 15:42:28 -05:00
resolv Remove $FreeBSD$: one-line sh pattern 2023-08-23 11:43:30 -06:00
riscv libc/riscv: Fix initial exec TLS mode for dynamically loaded shared objects 2025-12-15 17:56:36 +00:00
rpc libc: move NIS xdr_* symbols from rpc's to yp's Symbol.map 2024-05-29 11:42:17 -04:00
secure Remove $FreeBSD$: one-line sh pattern 2023-08-23 11:43:30 -06:00
softfloat Remove $FreeBSD$: one-line bare tag 2023-08-23 11:43:33 -06:00
stdio fgets.3: document gets_s() __STDC_WANT_LIB_EXT1__ 2024-12-27 10:49:31 -05:00
stdlib strfmon: Fix negative sign handling for C locale 2025-12-03 02:35:56 +00:00
stdtime libc: Add "Z" as TZ designator for strptime. 2025-10-22 10:53:28 -07:00
string libc: make strerror_rl() usable for libc 2024-04-30 03:49:52 +03:00
sys stat(2): Document the st_rdev field 2025-08-27 18:50:58 +00:00
tests strfmon: Fix negative sign handling for C locale 2025-12-03 02:35:56 +00:00
uuid Remove $FreeBSD$: two-line nroff pattern 2023-08-23 11:43:31 -06:00
x86 Canonicalize the name of the FreeBSD Foundation 2025-02-19 14:52:36 -05:00
xdr rpc: Fix the definition of xdr_void() 2024-11-05 01:05:31 +00:00
yp libc: move NIS xdr_* symbols from rpc's to yp's Symbol.map 2024-05-29 11:42:17 -04:00
libc.ldscript Remove $FreeBSD$: one-line .c comment pattern 2023-08-23 11:43:23 -06:00
libc_nossp.ldscript Remove $FreeBSD$: one-line .c comment pattern 2023-08-23 11:43:23 -06:00
Makefile libc: enable initial-exec (IE) as default thread-local storage model on arm 2024-11-22 10:41:47 -05:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-23 11:43:30 -06:00
Makefile.depend.options Remove $FreeBSD$: one-line sh pattern 2023-08-23 11:43:30 -06:00
Versions.def Create namespace for the symbols added during 15-CURRENT cycle 2024-02-11 03:40:29 +02:00