From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
To: "akamath996@gmail.com" <akamath996@gmail.com>,
"tom@tromey.com" <tom@tromey.com>,
"simon.marchi@polymtl.ca" <simon.marchi@polymtl.ca>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
SANGAMESH MALLAYYA <sangamesh.swamy@in.ibm.com>,
Aditya Kamath <Aditya.Kamath1@ibm.com>
Subject: Re: [PATCH v2 2/2] This patch adds support to debug thread local variables defined in shared libraries in AIX.
Date: Thu, 3 Sep 2026 15:29:12 +0000 [thread overview]
Message-ID: <7281fbc584ee75003dcd6fb8b2f41db739d68c96.camel@de.ibm.com> (raw)
In-Reply-To: <20260903085614.39532-2-akamath996@gmail.com>
Aditya Vidyadhar Kamath <akamath996@gmail.com> wrote:
>For global-dynamic/local-dynamic (R_TLSM): scan the .loader section
>for the R_TLSM relocation, read the 8-byte mod_id from the
>inferior's TOC, and dereference it as a TP-relative pointer to
>the per-thread block, then add the intra-module variable offset.
This is certainly more general than the original attempt, but ...
/* Match: the loader symbol's l_value equals the XCOFF static symbol
value that GDB received as 'sym_offset'. For R_TLS and R_TLS_IE
this is the TP-relative offset baked in at link time. For R_TLS_LD
this is the within-module variable offset. */
if ((CORE_ADDR)(int64_t) ldsym.l_value != sym_offset)
continue;
... I don't this logic can work. For the interesting case
(non-initial-exec modules), the sym_offset is *relative* to
the current module, which means that it does not at all
uniquely identify the symbol.
If you have two dynamic libraries, both defining a single
TLS symbol, they will both get offset 0. If you try to look
up a particular symbol in the relocation section using the
above logic, it will just look for offset 0 - but that could
randomly hit either of the two variables and therefore
result in the wrong module ID.
If you want to definitively identify the module ID of a
dynamic library from the relocations performed by the loader,
I think there's really only two options:
- if there is a R_TLSML in that library, it must resolve to
the current module ID (or 0 if it is actually initial-exec)
- otherwise, you need to scan all R_TLSM relocations in all
modules and check whether the *name* associated with the
relocation is found in the library you're interested in
(respecting search order); if yes, that's the module ID
for that library (or 0 for initial-exec)
That may be a bit inefficient, but I'm not really seeing
any better option here.
On the positive side, this means you can do the whole reloc
scanning fully in the fetch_tls_load_module_address hook
(since you only need the objfile - the offset doesn't help
you anything anyway), and simply return the module ID from
that hook. (That means you could even cache the module ID
in a per-objfile data structure to pay the price only once.)
Bye,
Ulrich
next prev parent reply other threads:[~2026-09-03 15:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 8:56 Aditya Vidyadhar Kamath
2026-09-03 15:29 ` Ulrich Weigand [this message]
2026-09-08 13:30 ` Aditya Kamath
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7281fbc584ee75003dcd6fb8b2f41db739d68c96.camel@de.ibm.com \
--to=ulrich.weigand@de.ibm.com \
--cc=Aditya.Kamath1@ibm.com \
--cc=akamath996@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=sangamesh.swamy@in.ibm.com \
--cc=simon.marchi@polymtl.ca \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox