From patchwork Wed Jun 3 14:28:15 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= X-Patchwork-Id: 136398 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F17C4BA2E23 for ; Wed, 3 Jun 2026 14:29:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F17C4BA2E23 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Logzqrie X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id EF8684BA2E0B for ; Wed, 3 Jun 2026 14:28:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF8684BA2E0B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EF8684BA2E0B Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780496908; cv=none; b=tBN4nVuWKWvsVu7fTe8q12bp/0b2v//mnHN67W3Ig+SGPaJlOHKiZieVPZVS7LIH9eAvp6B2kmCJVZGENwD5GCmXqiFr8A6g+307CRXdUqP8uzQ0Ia23W12uj7EnkJr4CD0kTgp5E0NPBFrvF4NvwbWziF98bVRgjZx8//9D8ls= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780496908; c=relaxed/simple; bh=M4yvbMFUesGaAjGsIrOtohiBKixyHi5prGl1FpxfAE8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Hc5FRsZa4kKZX+Q1lbgfTXWBrJ/PWYOAOV1g2r4LWtrO46P7wolRqob6Vn5DdrRkajmzJ6m57Ungp6C4Y7Kp8PG3ptwiEX8xxVIOxP5uYvB65pNQb/oAfD/2LUBwpt14CTNnOqMfdQBa5wQ5EjCDogv+EXQbO/zdLZ7UW7kCtBU= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Logzqrie DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF8684BA2E0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780496907; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oeQS/fFKLA/MuaXQrN3cyCjiHns+55SlrYoXuWUaOBs=; b=LogzqrieJM9cPfo29a8CGWbTUyAZeEwIZJ9v9pgIAGMWiLkl4fXGl/kvOTCWqm4IMYdRTv ZcBdS83ZmhZnnTgKbJ4RfJOFUeXnYvRfZpeenqxGv4y9H/Z9muHv/05aPXMgjUZ21hsfzk xg64sdCvZOSWJlbzmCnC6QLDM9uNp6Y= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-YYpEgCUON-ecDt1luK6WjA-1; Wed, 03 Jun 2026 10:28:24 -0400 X-MC-Unique: YYpEgCUON-ecDt1luK6WjA-1 X-Mimecast-MFC-AGG-ID: YYpEgCUON-ecDt1luK6WjA_1780496903 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7E0D119560AA; Wed, 3 Jun 2026 14:28:23 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.44.33.175]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 27828180049F; Wed, 3 Jun 2026 14:28:21 +0000 (UTC) From: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= To: libc-alpha@sourceware.org Cc: adhemerval.zanella@linaro.org Subject: [PATCH v1] elf: Improve diagnostics for static TLS exhaustion Date: Wed, 3 Jun 2026 16:28:15 +0200 Message-ID: <20260603142815.1564034-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: w9fizI_hK1iObihlkYmcctiJXqwuvG8zhtfV4Qr_Z-Y_1780496903 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_HOSTKARMA_W, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Improve the error diagnostics printed when static TLS allocation fails during dlopen. The CHECK_STATIC_TLS macro is updated to pass the fully resolved sym and the referencing map over to _dl_allocate_static_tls, modifying its signature. When _dl_allocate_static_tls is called, it now attempts to reconstruct what failed using _dl_exception_create_format. It displays: * The name of the symbol that triggers this. * Whether this is due to static TLS space being exhausted, or if the symbol has previously been used as global-dynamic and is now being tried to use as initial-exec. * If the symbol-defining map is different from the referencing map, it includes its name as well. * If static TLS is exhausted, includes requested size and available size. The change cascades through all architecture variants modifying their dl-machine calls to CHECK_STATIC_TLS to conform to the new prototype. --- Changes since v0: - Extracted TLS size/alignment calculation into a new inline helper _dl_static_tls_allocation to avoid duplication between the allocation and diagnostics paths. - Added /* XXX We cannot translate... */ comment blocks. - Removed spaces in GL(), GLRO(), and N_() macro uses. elf/dl-reloc.c | 138 ++++++++++++++++++------- elf/dl-static-tls.h | 4 +- sysdeps/aarch64/dl-machine.h | 4 +- sysdeps/alpha/dl-machine.h | 2 +- sysdeps/arc/dl-machine.h | 2 +- sysdeps/arm/dl-machine.h | 4 +- sysdeps/csky/dl-machine.h | 2 +- sysdeps/generic/ldsodefs.h | 4 +- sysdeps/hppa/dl-machine.h | 2 +- sysdeps/i386/dl-machine.h | 6 +- sysdeps/loongarch/dl-machine.h | 4 +- sysdeps/m68k/dl-machine.h | 2 +- sysdeps/microblaze/dl-machine.h | 2 +- sysdeps/mips/dl-machine.h | 2 +- sysdeps/or1k/dl-machine.h | 2 +- sysdeps/powerpc/powerpc32/dl-machine.c | 2 +- sysdeps/powerpc/powerpc32/dl-machine.h | 4 +- sysdeps/powerpc/powerpc64/dl-machine.h | 4 +- sysdeps/riscv/dl-machine.h | 2 +- sysdeps/s390/dl-machine.h | 2 +- sysdeps/sh/dl-machine.h | 2 +- sysdeps/sparc/sparc32/dl-machine.h | 4 +- sysdeps/sparc/sparc64/dl-machine.h | 4 +- sysdeps/x86_64/dl-machine.h | 4 +- 24 files changed, 134 insertions(+), 74 deletions(-) base-commit: 7193069543b0883b667d7c14d4b83fa3e8b2e1de diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index 15a6a4cffe..fdb56dfa9b 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -37,6 +37,47 @@ #endif +/* Return the number of bytes that would be allocated in the static + TLS block for MAP. If the available space is insufficient, return a + value greater than the available space to indicate failure. OFFSET_OUT + is updated with the TLS offset of the map. */ +static inline size_t +__attribute__ ((always_inline)) +_dl_static_tls_allocation (struct link_map *map, size_t *offset_out) +{ +#if TLS_TCB_AT_TP + size_t freebytes = GLRO(dl_tls_static_size) - GL(dl_tls_static_used); + if (freebytes < TLS_TCB_SIZE) + return TLS_TCB_SIZE + map->l_tls_blocksize; + freebytes -= TLS_TCB_SIZE; + + size_t blsize = map->l_tls_blocksize + map->l_tls_firstbyte_offset; + if (freebytes < blsize) + return TLS_TCB_SIZE + blsize; + + size_t n = (freebytes - blsize) / map->l_tls_align; + + /* Account optional static TLS surplus usage. */ + size_t use = freebytes - n * map->l_tls_align - map->l_tls_firstbyte_offset; + *offset_out = GL(dl_tls_static_used) + use; + return use; +#elif TLS_DTV_AT_TP + /* dl_tls_static_used includes the TCB at the beginning. */ + size_t offset = (ALIGN_UP(GL(dl_tls_static_used) + - map->l_tls_firstbyte_offset, + map->l_tls_align) + + map->l_tls_firstbyte_offset); + size_t used = offset + map->l_tls_blocksize; + + /* Account optional static TLS surplus usage. */ + size_t use = used - GL(dl_tls_static_used); + *offset_out = offset; + return use; +#else +# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" +#endif +} + /* We are trying to perform a static TLS relocation in MAP, but it was dynamically loaded. This can only work if there is enough surplus in the static TLS area already allocated for each running thread. If this @@ -54,57 +95,30 @@ _dl_try_allocate_static_tls (struct link_map *map, bool optional) /* If we've already used the variable with dynamic access, or if the alignment requirements are too high, fail. */ if (map->l_tls_offset == FORCED_DYNAMIC_TLS_OFFSET - || map->l_tls_align > GLRO (dl_tls_static_align)) + || map->l_tls_align > GLRO(dl_tls_static_align)) { fail: return -1; } -#if TLS_TCB_AT_TP - size_t freebytes = GLRO (dl_tls_static_size) - GL(dl_tls_static_used); - if (freebytes < TLS_TCB_SIZE) - goto fail; - freebytes -= TLS_TCB_SIZE; + size_t offset; + size_t use = _dl_static_tls_allocation (map, &offset); - size_t blsize = map->l_tls_blocksize + map->l_tls_firstbyte_offset; - if (freebytes < blsize) + if (use > GLRO(dl_tls_static_size) - GL(dl_tls_static_used)) goto fail; - size_t n = (freebytes - blsize) / map->l_tls_align; - /* Account optional static TLS surplus usage. */ - size_t use = freebytes - n * map->l_tls_align - map->l_tls_firstbyte_offset; - if (optional && use > GL(dl_tls_static_optional)) - goto fail; - else if (optional) - GL(dl_tls_static_optional) -= use; - - size_t offset = GL(dl_tls_static_used) + use; - - map->l_tls_offset = GL(dl_tls_static_used) = offset; -#elif TLS_DTV_AT_TP - /* dl_tls_static_used includes the TCB at the beginning. */ - size_t offset = (ALIGN_UP(GL(dl_tls_static_used) - - map->l_tls_firstbyte_offset, - map->l_tls_align) - + map->l_tls_firstbyte_offset); - size_t used = offset + map->l_tls_blocksize; - - if (used > GLRO (dl_tls_static_size)) - goto fail; - - /* Account optional static TLS surplus usage. */ - size_t use = used - GL(dl_tls_static_used); if (optional && use > GL(dl_tls_static_optional)) goto fail; else if (optional) GL(dl_tls_static_optional) -= use; map->l_tls_offset = offset; +#if TLS_TCB_AT_TP + GL(dl_tls_static_used) = offset; +#elif TLS_DTV_AT_TP map->l_tls_firstbyte_offset = GL(dl_tls_static_used); - GL(dl_tls_static_used) = used; -#else -# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" + GL(dl_tls_static_used) = offset + map->l_tls_blocksize; #endif /* Initialise the static TLS region, the map may not yet be l_relocated (a @@ -131,13 +145,57 @@ _dl_try_allocate_static_tls (struct link_map *map, bool optional) not be inlined as much as possible. */ void __attribute_noinline__ -_dl_allocate_static_tls (struct link_map *map) +_dl_allocate_static_tls (struct link_map *map, struct link_map *sym_map, + const ElfW(Sym) *sym) { - if (map->l_tls_offset == FORCED_DYNAMIC_TLS_OFFSET - || _dl_try_allocate_static_tls (map, false)) + if (sym_map->l_tls_offset == FORCED_DYNAMIC_TLS_OFFSET + || _dl_try_allocate_static_tls (sym_map, false)) { - _dl_signal_error (0, map->l_name, NULL, N_("\ -cannot allocate memory in static TLS block")); + const char *symname = "unknown"; + const char *def_map_info = ""; + const char *def_map_name = ""; + struct dl_exception exception; + + if (sym != NULL) + { + const char *strtab + = (const char *) D_PTR (sym_map, l_info[DT_STRTAB]); + symname = strtab + sym->st_name; + if (symname[0] == '\0') + symname = "unknown"; + } + + if (sym_map != map) + { + def_map_info = " defined in "; + def_map_name = DSO_FILENAME (sym_map->l_name); + } + + if (sym_map->l_tls_offset == FORCED_DYNAMIC_TLS_OFFSET) + { + /* XXX We cannot translate the message. */ + _dl_exception_create_format ( + &exception, DSO_FILENAME (map->l_name), + "cannot allocate memory in static TLS block: " + "%s%s%s: previously used as global-dynamic", + symname, def_map_info, def_map_name); + } + else + { + size_t offset; + size_t requested = _dl_static_tls_allocation (sym_map, &offset); + size_t available + = (GLRO(dl_tls_static_size) - GL(dl_tls_static_used)); + + /* XXX We cannot translate the message. */ + _dl_exception_create_format ( + &exception, DSO_FILENAME (map->l_name), + "cannot allocate memory in static TLS block: " + "%s%s%s: requested %zx, available %zx", + symname, def_map_info, def_map_name, requested, available); + } + + _dl_signal_exception (0, &exception, N_("TLS allocation error")); } } diff --git a/elf/dl-static-tls.h b/elf/dl-static-tls.h index 5bc5dbe0c3..b3cd6299f8 100644 --- a/elf/dl-static-tls.h +++ b/elf/dl-static-tls.h @@ -33,10 +33,10 @@ && ((sym_map)->l_tls_offset \ != FORCED_DYNAMIC_TLS_OFFSET), 1)) -#define CHECK_STATIC_TLS(map, sym_map) \ +#define CHECK_STATIC_TLS(map, sym_map, sym) \ do { \ if (!HAVE_STATIC_TLS (map, sym_map)) \ - _dl_allocate_static_tls (sym_map); \ + _dl_allocate_static_tls (map, sym_map, sym); \ } while (0) #define TRY_STATIC_TLS(map, sym_map) \ diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h index 15651c62f3..7605b760b8 100644 --- a/sysdeps/aarch64/dl-machine.h +++ b/sysdeps/aarch64/dl-machine.h @@ -237,7 +237,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], else { # ifndef SHARED - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); # else if (!TRY_STATIC_TLS (map, sym_map)) { @@ -271,7 +271,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], case R_AARCH64_TLS_TPREL: if (sym) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr = sym->st_value + reloc->r_addend + sym_map->l_tls_offset; } diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h index 77686c728e..7c500ea850 100644 --- a/sysdeps/alpha/dl-machine.h +++ b/sysdeps/alpha/dl-machine.h @@ -405,7 +405,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], # else if (sym_map) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr = sym_raw_value + sym_map->l_tls_offset; } # endif diff --git a/sysdeps/arc/dl-machine.h b/sysdeps/arc/dl-machine.h index 50c9e877ae..7bb1b7be98 100644 --- a/sysdeps/arc/dl-machine.h +++ b/sysdeps/arc/dl-machine.h @@ -283,7 +283,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], case R_ARC_TLS_TPOFF: if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr = sym_map->l_tls_offset + sym->st_value + reloc->r_addend; } break; diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h index 15cced693e..8b1b0dc035 100644 --- a/sysdeps/arm/dl-machine.h +++ b/sysdeps/arm/dl-machine.h @@ -383,7 +383,7 @@ elf_machine_rel (struct link_map *map, struct r_scope_elem *scope[], # ifndef RTLD_BOOTSTRAP # ifndef SHARED - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); # else if (!TRY_STATIC_TLS (map, sym_map)) { @@ -424,7 +424,7 @@ elf_machine_rel (struct link_map *map, struct r_scope_elem *scope[], case R_ARM_TLS_TPOFF32: if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr += sym->st_value + sym_map->l_tls_offset; } break; diff --git a/sysdeps/csky/dl-machine.h b/sysdeps/csky/dl-machine.h index 57444f4cce..a5804af4df 100644 --- a/sysdeps/csky/dl-machine.h +++ b/sysdeps/csky/dl-machine.h @@ -301,7 +301,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], case R_CKCORE_TLS_TPOFF32: if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr = (sym->st_value + sym_map->l_tls_offset + reloc->r_addend); } diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 24529db8a1..54e92b08b7 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -1228,7 +1228,9 @@ rtld_hidden_proto (_dl_allocate_tls) /* Get size and alignment requirements of the static TLS block. */ extern void _dl_get_tls_static_info (size_t *sizep, size_t *alignp); -extern void _dl_allocate_static_tls (struct link_map *map) attribute_hidden; +extern void _dl_allocate_static_tls (struct link_map *map, + struct link_map *sym_map, + const ElfW(Sym) *sym) attribute_hidden; extern void *_dl_allocate_tls_storage (void) attribute_hidden; extern void *_dl_allocate_tls_init (void *result, bool main_thread); diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h index f931087869..9bdbd85b6b 100644 --- a/sysdeps/hppa/dl-machine.h +++ b/sysdeps/hppa/dl-machine.h @@ -714,7 +714,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], /* The offset is negative, forward from the thread pointer */ if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); value = sym_map->l_tls_offset + sym->st_value + reloc->r_addend; } break; diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index dd49079d75..b074c40dbf 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -342,7 +342,7 @@ and creates an unsatisfiable circular dependency.\n", { # ifndef RTLD_BOOTSTRAP # ifndef SHARED - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); # else if (!TRY_STATIC_TLS (map, sym_map)) { @@ -372,7 +372,7 @@ and creates an unsatisfiable circular dependency.\n", block we subtract the offset from that of the TLS block. */ if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr += sym_map->l_tls_offset - sym->st_value; } # endif @@ -387,7 +387,7 @@ and creates an unsatisfiable circular dependency.\n", thread pointer. */ if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr += sym->st_value - sym_map->l_tls_offset; } # endif diff --git a/sysdeps/loongarch/dl-machine.h b/sysdeps/loongarch/dl-machine.h index e8ee50b810..ae295264ae 100644 --- a/sysdeps/loongarch/dl-machine.h +++ b/sysdeps/loongarch/dl-machine.h @@ -205,7 +205,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], break; case __WORDSIZE == 64 ? R_LARCH_TLS_TPREL64 : R_LARCH_TLS_TPREL32: - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *addr_field = TLS_TPREL_VALUE (sym_map, sym) + reloc->r_addend; break; @@ -220,7 +220,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], else { # ifndef SHARED - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); # else if (!TRY_STATIC_TLS (map, sym_map)) { diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h index e61dd27f5f..48b7705d71 100644 --- a/sysdeps/m68k/dl-machine.h +++ b/sysdeps/m68k/dl-machine.h @@ -283,7 +283,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], case R_68K_TLS_TPREL32: if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr = TLS_TPREL_VALUE (sym_map, sym, reloc); } break; diff --git a/sysdeps/microblaze/dl-machine.h b/sysdeps/microblaze/dl-machine.h index 62031a589c..da59c00bea 100644 --- a/sysdeps/microblaze/dl-machine.h +++ b/sysdeps/microblaze/dl-machine.h @@ -261,7 +261,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], { if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr = sym->st_value + sym_map->l_tls_offset + reloc->r_addend; } } diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h index 79d0df82c7..75cb5b10bb 100644 --- a/sysdeps/mips/dl-machine.h +++ b/sysdeps/mips/dl-machine.h @@ -474,7 +474,7 @@ elf_machine_reloc (struct link_map *map, struct r_scope_elem *scope[], case R_MIPS_TLS_TPREL64: if (sym) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); if (inplace_p) r_addend = *addr_field; *addr_field = r_addend + TLS_TPREL_VALUE (sym_map, sym); diff --git a/sysdeps/or1k/dl-machine.h b/sysdeps/or1k/dl-machine.h index e6d88aabd9..b06da7c7c4 100644 --- a/sysdeps/or1k/dl-machine.h +++ b/sysdeps/or1k/dl-machine.h @@ -254,7 +254,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], # else if (sym_map != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr = sym->st_value + reloc->r_addend + sym_map->l_tls_offset - TLS_TCB_SIZE; } diff --git a/sysdeps/powerpc/powerpc32/dl-machine.c b/sysdeps/powerpc/powerpc32/dl-machine.c index 7127ebc32c..ebdfc63a47 100644 --- a/sysdeps/powerpc/powerpc32/dl-machine.c +++ b/sysdeps/powerpc/powerpc32/dl-machine.c @@ -566,7 +566,7 @@ __process_machine_rela (struct link_map *map, case R_PPC_TPREL##suffix: \ if (sym_map != NULL) \ { \ - CHECK_STATIC_TLS (map, sym_map); \ + CHECK_STATIC_TLS (map, sym_map, sym); \ do_reloc##suffix ("R_PPC_TPREL"#suffix, \ TLS_TPREL_VALUE (sym_map, sym, reloc)); \ } \ diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h index e07a44a5a5..e42f6fd399 100644 --- a/sysdeps/powerpc/powerpc32/dl-machine.h +++ b/sysdeps/powerpc/powerpc32/dl-machine.h @@ -362,7 +362,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], else if (sym_map != NULL) { #ifndef SHARED - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); #else if (TRY_STATIC_TLS (map, sym_map)) #endif @@ -415,7 +415,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], if (!NOT_BOOTSTRAP || sym_map != NULL) { if (NOT_BOOTSTRAP) - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr = TLS_TPREL_VALUE (sym_map, sym, reloc); } break; diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h index 1f5d7a0170..cd4b3ab2f3 100644 --- a/sysdeps/powerpc/powerpc64/dl-machine.h +++ b/sysdeps/powerpc/powerpc64/dl-machine.h @@ -628,7 +628,7 @@ elf_machine_tprel (struct link_map *map, #ifndef RTLD_BOOTSTRAP if (sym_map) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); #endif return TLS_TPREL_VALUE (sym_map, sym, reloc); #ifndef RTLD_BOOTSTRAP @@ -741,7 +741,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], if (sym_map != NULL) { # ifndef SHARED - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); # else if (TRY_STATIC_TLS (map, sym_map)) # endif diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h index babb52af20..3e3e51f82e 100644 --- a/sysdeps/riscv/dl-machine.h +++ b/sysdeps/riscv/dl-machine.h @@ -215,7 +215,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], case __WORDSIZE == 64 ? R_RISCV_TLS_TPREL64 : R_RISCV_TLS_TPREL32: if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *addr_field = TLS_TPREL_VALUE (sym_map, sym) + reloc->r_addend; } break; diff --git a/sysdeps/s390/dl-machine.h b/sysdeps/s390/dl-machine.h index ac27644b05..b8c7c54a3b 100644 --- a/sysdeps/s390/dl-machine.h +++ b/sysdeps/s390/dl-machine.h @@ -327,7 +327,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], thread pointer. */ if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr = (sym->st_value + reloc->r_addend - sym_map->l_tls_offset); } diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h index 79d9aa65cc..e0b68dde8e 100644 --- a/sysdeps/sh/dl-machine.h +++ b/sysdeps/sh/dl-machine.h @@ -371,7 +371,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], we add the offset from that of the TLS block. */ if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr = sym_map->l_tls_offset + sym->st_value + reloc->r_addend; } diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h index 3771339a04..946c68c7e4 100644 --- a/sysdeps/sparc/sparc32/dl-machine.h +++ b/sysdeps/sparc/sparc32/dl-machine.h @@ -371,7 +371,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], thread pointer. */ if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr = sym->st_value - sym_map->l_tls_offset + reloc->r_addend; } @@ -381,7 +381,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], case R_SPARC_TLS_LE_LOX10: if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); value = sym->st_value - sym_map->l_tls_offset + reloc->r_addend; if (r_type == R_SPARC_TLS_LE_HIX22) diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h index 8a1a38d170..c4eefe11d2 100644 --- a/sysdeps/sparc/sparc64/dl-machine.h +++ b/sysdeps/sparc/sparc64/dl-machine.h @@ -387,7 +387,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], thread pointer. */ if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); *reloc_addr = sym->st_value - sym_map->l_tls_offset + reloc->r_addend; } @@ -397,7 +397,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], case R_SPARC_TLS_LE_LOX10: if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); value = sym->st_value - sym_map->l_tls_offset + reloc->r_addend; if (r_type == R_SPARC_TLS_LE_HIX22) diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index a94cb1a8af..f36e55b602 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -372,7 +372,7 @@ and creates an unsatisfiable circular dependency.\n", else { # ifndef SHARED - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); # else if (!TRY_STATIC_TLS (map, sym_map)) { @@ -394,7 +394,7 @@ and creates an unsatisfiable circular dependency.\n", /* The offset is negative, forward from the thread pointer. */ if (sym != NULL) { - CHECK_STATIC_TLS (map, sym_map); + CHECK_STATIC_TLS (map, sym_map, sym); /* We know the offset of the object the symbol is contained in. It is a negative value which will be added to the thread pointer. */