Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Aditya Kamath <Aditya.Kamath1@ibm.com>
To: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	"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>
Subject: Re: [PATCH v4 2/3] Add support for TLS variables in shared libraries on AIX.
Date: Tue, 22 Sep 2026 11:31:29 +0000	[thread overview]
Message-ID: <DSWPR15MB319817EE845B0FFF7125BDEB01D6832@DSWPR15MB319817.namprd15.prod.outlook.com> (raw)
In-Reply-To: <405a947722b44e71d60ca1e8667a4660bcee58b2.camel@de.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 2357 bytes --]

Hi Ulrich,

Thank you for the update. Please see my comments below. I am sending v5 version of the patch series.

>That last part I suspect still won't work correctly in all cases:

>+      /* l_value holds the link-time TP-relative offset.  It is unique
>+        within a module, so matching against static_offset identifies
>+        exactly the right variable.  */
>+      if ((CORE_ADDR)(int64_t) ldsym.l_value != static_offset)
>+       continue;

>Sure, the offset is unique within the module where the TLS variable
>is defined.  But you are not actually guaranteed to be within that
>module at this point.  In fact, more likely than not, "objfile” at
>this point is some *other* module that has a *reference* to the
>TLS variable in question - or actually some *other* TLS variable
>defined in another module with the same static offset …

Please check the rs6000_aix_objfile_exports_symbol where name is matched to the owning library before l_value is compared


>I'm not sure how to handle the R_TLSML case - I think if a module
>has that relocation, there should also be at least one instance
>of an R_TLS_LD to a symbol in the module, and then you could
>again compute the block offset.

This is implemented implicitly. The runtime TOC value for an R_TLS_LD slot in an initial-exec library already holds the loader-adjusted absolute TP-relative offset, so reading it directly gives the right answer without needing a separate block-offset computation.

>However, I guess depending on compiler options it might also be
>the case that all references to TLS symbols in a given module
>happen to only use R_TLS_IE - in that case, you know the module
>must be in the initial-exec segment (i.e. module ID zero), and
>then again get the offset from the R_TLS_IE relocated value.
In v5 of the patch rs6000_aix_find_initial_exec_tls_offset () only scans R_TLS and R_TLS_LD slots , it does not scan R_TLS_IE. But R_TLS_IE slots don't need scanning, the linker writes the final absolute TP-relative offset directly into the XCOFF symbol value at link time, so offset (the static symbol value GDB received) is already correct. When no R_TLS/R_TLS_LD slot is found, the code falls through to:

return tp + (CORE_ADDR)(int64_t) offset;

Let me know if I missed anything that we need.


Thanks and regards,

Aditya.

[-- Attachment #2: Type: text/html, Size: 7189 bytes --]

      reply	other threads:[~2026-09-22 11:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 10:15 Aditya Vidyadhar Kamath
2026-09-10 10:46 ` Ulrich Weigand
2026-09-22 11:31   ` Aditya Kamath [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=DSWPR15MB319817EE845B0FFF7125BDEB01D6832@DSWPR15MB319817.namprd15.prod.outlook.com \
    --to=aditya.kamath1@ibm.com \
    --cc=Ulrich.Weigand@de.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