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>,
PRAJWAL B MEHENDARKAR <PRAJWAL.B.MEHENDARKAR@ibm.com>,
Aditya Kamath <Aditya.Kamath1@ibm.com>
Subject: Re: [PATCH v1] Add TLS variable debug support for AIX [ 64-bit XCOFF files only]
Date: Wed, 29 Jul 2026 13:16:18 +0000 [thread overview]
Message-ID: <bd16314c7b6fe5f7ec87f5f4afa7892d595749fa.camel@de.ibm.com> (raw)
In-Reply-To: <20260729093301.16401-2-akamath996@gmail.com>
Aditya Vidyadhar Kamath <akamath996@gmail.com> wrote:
>+ The thread pointer in AIX (64-bit) is located at R13.
>+ The value of the XCOFF symbol is a signed offset from the thread
>+ pointer for the Local Exec TLS model, which is the only model that
>+ the AIX toolchain presently emits for executables. The TLS
variable's
>+ per-thread address is as follows since GDB provides that raw
symbol value as OFFSET:
>+
>+ address = (int64_t) offset + thread_pointer */
This doesn't look right to me. The issue is not so much the
"TLS model", which is mostly a matter of optimization. The
issue is more fundamental: thread-local variables defined in
libraries loaded with dlopen *cannot* be accessed directly
relative to the thread pointer, because the storage for
those is only allocated at dlopen time and not statically
known at compile or link time.
It is of course true that thread-local variables defined in
the main executable (or in libraries pulled in at startup)
can be accessed this way. But your code doesn't even attempt
to verify that the variable in question *is* one of those,
so it will simply access random memory if used on a variable
in a dlopen'ed library.
Ideally, you should be able to implement full support (by
accessing the AIX libc equivalent of the DTV). If that is
not possible for some reason, then you should at least
restrict the implementation to variables guaranteed to
work (e.g. by checking whether the objfile passsed to
fetch_tls_load_module_address corresponds to the main
executable or an initially loaded library).
Bye,
Ulrich
prev parent reply other threads:[~2026-07-29 13:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 9:33 Aditya Vidyadhar Kamath
2026-07-29 13:16 ` Ulrich Weigand [this message]
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=bd16314c7b6fe5f7ec87f5f4afa7892d595749fa.camel@de.ibm.com \
--to=ulrich.weigand@de.ibm.com \
--cc=Aditya.Kamath1@ibm.com \
--cc=PRAJWAL.B.MEHENDARKAR@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