From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 43DCD3858C2C for ; Fri, 29 Dec 2023 09:59:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 43DCD3858C2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 43DCD3858C2C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703843951; cv=none; b=lR/OhjuMdRg+1BU6yH0wUgbG+K/wsOP0GBDV8v2jIyBo3g3I6L92fl3l4kXaQVqgsuXnWwXNi00X/Z44l3ID2MGmoo+Av5HCSqy6h99awxkVYfJOAKeKKRzKBucEIFNNOwClO5mBOf0H424AtpTNg8kqHPBF3jprIBZQU+r7sYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703843951; c=relaxed/simple; bh=OtsRXx6BBsJ4Dp02u9/k5MTBTNFrVeGdXcaE6eWWsDA=; h=Subject:To:From:Message-ID:Date:MIME-Version; b=JTORpnrJ+rwfOcbHJUoAbHzFcneszUmohS1UiKLTdkGWd3ZVvmwwWXkdkk9lQSMUPaNjENgxmuzjtpHHjsrkM6zoCO3CAOJWsYA6pPZaeEMWf2gj/8czadGjwIp77vs3bZSCmaRWJaraRuZDbHbI7FpksD0cb/mvUWMM4X8+84c= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.20.4.171]) by gateway (Coremail) with SMTP id _____8AxjutpmI5lBm0AAA--.1989S3; Fri, 29 Dec 2023 17:59:05 +0800 (CST) Received: from [10.20.4.171] (unknown [10.20.4.171]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxG+RomI5lscIPAA--.51833S3; Fri, 29 Dec 2023 17:59:05 +0800 (CST) Subject: Re: [PATCH] LoongArch: Update comment about bottom bit usage in TLS GOT construction To: Tatsuyuki Ishi Cc: binutils@sourceware.org, Lulu Cai , chenglulu@loongson.cn, hejinyang@loongson.cn, i.swmail@xen0n.name, liuzhensong@loongson.cn, luweining@loongson.cn, Fangrui Song , nickc@redhat.com, wanglei@loongson.cn, xry111@xry111.site, xuchenghua@loongson.cn References: <20231228145802.74719-1-ishitatsuyuki@gmail.com> <20231228145802.74719-3-ishitatsuyuki@gmail.com> <2E548645-1BD7-4B21-B1D0-D5961A11FC0D@gmail.com> From: mengqinggang Message-ID: <6ef9bbd3-8bd6-44b1-22ca-757c4108f883@loongson.cn> Date: Fri, 29 Dec 2023 17:59:04 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <2E548645-1BD7-4B21-B1D0-D5961A11FC0D@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID:AQAAf8BxG+RomI5lscIPAA--.51833S3 X-CM-SenderInfo: 5phqw15lqjwttqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoWxJF1xAFWrKFy8Cr48JF13GFX_yoW5Wr4kpr WSya45try8Ww1xKw12vw18uFWru34xGw17GF95tFW8trykA3s2qFyvq3yF9ay8Xr4xArW2 vry0gayUur1DAacCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9ab4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lc7I2V7IY0VAS07 AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C2 67AKxVWUAVWUtwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI 8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWU CwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r 1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsG vfC2KfnxnUUI43ZEXa7IU8j-e5UUUUU== X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 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: