git: 03801d449a37 - main - rtld-elf/riscv: Don't allocate static TLS for dynamic TLS relocations

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Wed, 28 May 2025 20:28:07 UTC
The branch main has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=03801d449a3731cb643a51625c8c4d5d07b2e54c

commit 03801d449a3731cb643a51625c8c4d5d07b2e54c
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2025-05-28 20:22:15 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2025-05-28 20:22:15 +0000

    rtld-elf/riscv: Don't allocate static TLS for dynamic TLS relocations
    
    Provided you don't run out of extra static TLS space this should work,
    but it's wholly unnecessary and not how things are supposed to be done.
    Only static TLS relocations should allocate static TLS.
    
    Reviewed by:    kib
    Fixes:          4b1859c0e943 ("Add support for RISC-V architecture.")
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D50563
---
 libexec/rtld-elf/riscv/reloc.c | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/libexec/rtld-elf/riscv/reloc.c b/libexec/rtld-elf/riscv/reloc.c
index 4b61c4b9a061..cfa474aa93b7 100644
--- a/libexec/rtld-elf/riscv/reloc.c
+++ b/libexec/rtld-elf/riscv/reloc.c
@@ -404,23 +404,6 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
 			    lockstate);
 			if (def == NULL)
 				return (-1);
-			/*
-			 * We lazily allocate offsets for static TLS as we
-			 * see the first relocation that references the
-			 * TLS block. This allows us to support (small
-			 * amounts of) static TLS in dynamically loaded
-			 * modules. If we run out of space, we generate an
-			 * error.
-			 */
-			if (!defobj->tls_static) {
-				if (!allocate_tls_offset(
-				    __DECONST(Obj_Entry *, defobj))) {
-					_rtld_error(
-					    "%s: No space available for static "
-					    "Thread Local Storage", obj->path);
-					return (-1);
-				}
-			}
 
 			*where += (Elf_Addr)(def->st_value + rela->r_addend
 			    - TLS_DTV_OFFSET);