From: mengqinggang <mengqinggang@loongson.cn>
To: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
Cc: binutils@sourceware.org, Lulu Cai <cailulu@loongson.cn>,
chenglulu@loongson.cn, hejinyang@loongson.cn,
i.swmail@xen0n.name, liuzhensong@loongson.cn,
luweining@loongson.cn, Fangrui Song <maskray@google.com>,
nickc@redhat.com, wanglei@loongson.cn, xry111@xry111.site,
xuchenghua@loongson.cn
Subject: Re: [PATCH] LoongArch: Update comment about bottom bit usage in TLS GOT construction
Date: Fri, 29 Dec 2023 17:59:04 +0800 [thread overview]
Message-ID: <6ef9bbd3-8bd6-44b1-22ca-757c4108f883@loongson.cn> (raw)
In-Reply-To: <2E548645-1BD7-4B21-B1D0-D5961A11FC0D@gmail.com>
These comments mainly explain the issue of another implementation method.
If the code like below, TLS IE and GD processed separately, we need two
bits as flags.
case R_LARCH_TLS_IE_PC_HI20:
if ((got_off & 1) == 0)
{
...
}
case R_LARCH_TLS_GD_PC_HI20:
if ((got_off & 2) == 0)
{
...
}
在 2023/12/29 下午5:11, Tatsuyuki Ishi 写道:
>> On Dec 29, 2023, at 17:50, mengqinggang <mengqinggang@loongson.cn> wrote:
>>
>> At the beginning of implementation, we try to IE and GD only generate their own GOT entry,
>> so we need two bits to do the flags.
> I checked the tree back at the date the comment was introduced (6d13722a: "bfd: Add supported for LoongArch new relocations.”). Even at that time, there was no |= 2 accesses, so if my understanding is correct, this comment was wrong from the beginning.
>
> Could you clarify what you mean here, in particular what “At the beginning of implementation” refer to?
>
>> 在 2023/12/28 下午10:58, Tatsuyuki Ishi 写道:
>>> The GOT assignment logic, likely copied from another backend, does not in
>>> fact require multiple flags to construct multiple type of slots. Instead,
>>> all slots are initialized on the first relocation encountered. Update
>>> comment to avoid confusion.
>>> ---
>>> bfd/elfnn-loongarch.c | 17 +++++++----------
>>> 1 file changed, 7 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
>>> index 64c34e99261..d66dcee1100 100644
>>> --- a/bfd/elfnn-loongarch.c
>>> +++ b/bfd/elfnn-loongarch.c
>>> @@ -3656,16 +3656,13 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
>>> relocation -= elf_hash_table (info)->tls_sec->vma;
>>> break;
>>> - /* TLS IE LD/GD process separately is troublesome.
>>> - When a symbol is both ie and LD/GD, h->got.off |= 1
>>> - make only one type be relocated. We must use
>>> - h->got.offset |= 1 and h->got.offset |= 2
>>> - diff IE and LD/GD. And all (got_off & (~(bfd_vma)1))
>>> - (IE LD/GD and reusable GOT reloc) must change to
>>> - (got_off & (~(bfd_vma)3)), beause we use lowest 2 bits
>>> - as a tag.
>>> - Now, LD and GD is both GOT_TLS_GD type, LD seems to
>>> - can be omitted. */
>>> + /* The bottom bit of h->got.offset is (ab)used as a flag.
>>> + Upon encountering the first TLS relocation, we initialize all GOT
>>> + slots for the corresponding symbol and set the bottom bit to 1.
>>> +
>>> + The second and subsequent relocations will check the flag, see that
>>> + the slot is already initialized, and move on to just relocating the
>>> + entry. */
>>> case R_LARCH_TLS_IE_PC_HI20:
>>> case R_LARCH_TLS_IE_HI20:
>>> case R_LARCH_TLS_LD_PC_HI20:
next prev parent reply other threads:[~2023-12-29 9:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-28 14:58 [PATCH] LoongArch: Do not add DF_STATIC_TLS for TLS LE Tatsuyuki Ishi
2023-12-28 14:58 ` [PATCH] LoongArch: Use tab to indent assembly in TLSDESC test suite Tatsuyuki Ishi
2024-01-22 9:47 ` mengqinggang
2023-12-28 14:58 ` [PATCH] LoongArch: Update comment about bottom bit usage in TLS GOT construction Tatsuyuki Ishi
2023-12-29 8:50 ` mengqinggang
2023-12-29 9:11 ` Tatsuyuki Ishi
2023-12-29 9:59 ` mengqinggang [this message]
2024-01-22 5:45 ` [PATCH] LoongArch: Do not add DF_STATIC_TLS for TLS LE Tatsuyuki Ishi
2024-01-22 5:48 ` Fangrui Song
2024-01-22 6:51 ` Xi Ruoyao
2024-01-22 7:11 ` Fangrui Song
2024-01-22 8:27 ` mengqinggang
2024-01-22 9:46 ` mengqinggang
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=6ef9bbd3-8bd6-44b1-22ca-757c4108f883@loongson.cn \
--to=mengqinggang@loongson.cn \
--cc=binutils@sourceware.org \
--cc=cailulu@loongson.cn \
--cc=chenglulu@loongson.cn \
--cc=hejinyang@loongson.cn \
--cc=i.swmail@xen0n.name \
--cc=ishitatsuyuki@gmail.com \
--cc=liuzhensong@loongson.cn \
--cc=luweining@loongson.cn \
--cc=maskray@google.com \
--cc=nickc@redhat.com \
--cc=wanglei@loongson.cn \
--cc=xry111@xry111.site \
--cc=xuchenghua@loongson.cn \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).