From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oXyKIeAnoGrnRTcAWB0awg (envelope-from ) for ; Tue, 08 Sep 2026 11:21:04 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=Crk044P2; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 81B011E033; Tue, 08 Sep 2026 11:21:04 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1FD791E033 for ; Tue, 08 Sep 2026 11:21:03 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A8DD44BAE7F4 for ; Tue, 8 Sep 2026 15:21:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8DD44BAE7F4 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=Crk044P2 Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 6212D4BA79BF for ; Tue, 8 Sep 2026 15:20:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6212D4BA79BF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6212D4BA79BF Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788880839; cv=none; b=M9YWKJO+DpMDRH07g62owY2osCoCT0gs1//JvaENt5DLRN2vN8q5glQqu4m0igKXY+tWel6B99Q6FsQjb6cGZyvGcIXz8nxhuT0ck4faTaFURpcYx9s6SrDiPgVmZ4uRPq38iZRTM3l5u39p9qdiaGlJzDbmBfdbWQcuje9Fe8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788880839; c=relaxed/simple; bh=6NDA/8hhWk4br+Jvy8EkzKd+aRhoLPxtKdr7ZYaahN4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=mkBrodZjjOiQObtxK7uq0InlvODBHU4qXK4oy0uA5hGa+gOK8l4Coh9R9wq0cmLveMNTW4UoCmLVf5RuUXrB0lk5OiopviV6EEFodgWZMNQ9DIdYZ9s91paypUEnwxbnU/YVMZa7cdZq9Sr1dgBt7LnVtWIe5WsjDfLh60V/gD4= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=Crk044P2 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6212D4BA79BF Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 688FKRwM097737 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 8 Sep 2026 11:20:32 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 688FKRwM097737 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1788880833; bh=5rCiVKozHdaO8cZrKFPg5Rv01O16oytj51mQGdebgoE=; h=Date:Subject:To:Cc:From:In-Reply-To:From; b=Crk044P2sG7JJuo2GIcblUFW+tCpQts0UoCqwN974/ZgLbEH8lF6SX4Xr537XhZ65 q7OFRIvC4nvLvtd0FtYi3URMH8ds7ZKhMtlOXVZzXO/wX0Px939nj9yObxlVWEhVpg Z8VJwgSq+ltXNA+tg5/sNTZJLV/VHh1U8aFwQJETLIjCDluNBNpKMPKUPGYhABSQRI WLUuQGbq+iZ3IslqAFZCgcCFQ+e0a0oEVCP+5hEsKMrWUsqLPSpdB8lKQRBq5ezkJJ e/jpWj5n0WiYPCBRvke14Yjs3+Y/wNYZqFoBvZ9/5uPP9M5KxHWucAQ/iSGJeMgeTl zaFEbuNreCbOA== Received: by simark.ca (Postfix) id EA4971E033; Tue, 08 Sep 2026 11:20:26 -0400 (EDT) Message-ID: <5bbabb63-9cf0-4d66-b254-e6b4c2cf201c@polymtl.ca> Date: Tue, 8 Sep 2026 11:20:26 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/3] This patch adds support to debug thread local variables defined in shared libraries in AIX. To: Aditya Vidyadhar Kamath , ulrich.weigand@de.ibm.com, tom@tromey.com Cc: gdb-patches@sourceware.org, Aditya.Kamath1@ibm.com, sangamesh.swamy@in.ibm.com References: <20260908133222.70926-2-akamath996@gmail.com> Content-Language: fr From: Simon Marchi In-Reply-To: <20260908133222.70926-2-akamath996@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 8 Sep 2026 15:20:27 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 9/8/26 9:32 AM, Aditya Vidyadhar Kamath wrote: > From: Aditya Vidyadhar Kamath > > Sample debug output of this patch is as below > Thread 3 hit Breakpoint 1, thread_runner (arg=0x2) at tls_main.c:36 > 36 volatile int bp_here = 0; (void)bp_here; > > $3 = 20 > $4 = 40 > thread 2: my_tls_var=20 lib_tls_var=40 > [Thread 1 (tid 101646715) (id 1) exited] > [Thread 515 (tid 88015327) (id 3) exited] > [Inferior 1 (process 21758254) exited normally] > > where lib_tls_var=40 is a variable from a thread library. > > Module-id resolution for shared libraries uses two strategies: > > 1. R_TLSML (local-dynamic): there is exactly one R_TLSML reloc per > module, and the loader always writes that module's own id into the > corresponding TOC slot. Read it from the inferior and return it. > > 2. R_TLSM (global-dynamic): each R_TLSM relocation in any loaded module's .loader > section references the library that exports the named TLS symbol. > Scan R_TLSM relocs across all loaded objfiles for each, resolve the > loader symbol name and check whether the library of interest exports > it. If so, read the TOC slot value, that is the library's module-id. > Matching is done by symbol name, not by symbol value, so two > libraries that both define a TLS variable at within-module offset 0 > are distinguished correctly. > > The module-id is cached in a per-objfile structure so the .loader scan > is paid only once per shared library. > > Module-id 0 is a valid AIX loader assignment in initial-exec model and > is not treated as "not yet allocated". The main executable is > distinguished from a module-id-0 library by returning the out-of-band > sentinel XCOFF_MODID_MAIN_EXE (UINT64_MAX) instead of 0. > > the address computation is done using 3 cases, they are: > > - XCOFF_MODID_MAIN_EXE: local-exec where the XCOFF symbol value is the > signed TP-relative offset directly; address = tp + offset. > > - module-id 0 is initial-execed shared library where the AIX loader merges all > initial-exec modules into one contiguous TLS segment and adjusts each > variable's TP-relative offset accordingly. The link-time XCOFF symbol > value does not necessarily equal the runtime offset. The patch scans > the library's R_TLS slots and matches by l_value (unique within one > module) to find the slot the loader filled with the actual runtime > TP-relative offset, then computes address = tp + runtime_offset. > > - module-id n > 0 is global-dynamic where we iterate the per-thread thread vector: > tls_base = thread_vector[n]; address = tls_base + offset. Please reword the commit subject to something like: Add support for TLS variables in shared libraries on AIX Simon