From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id 45DB33858D33 for ; Fri, 29 Dec 2023 09:12:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 45DB33858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 45DB33858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703841141; cv=none; b=utbKXTzb1+sUUD/gL0f5qEeRvPKAwfgliWs7HAqOGhMgRRpwv7t1v2+Ru9SYM00b4N6b05wvI/sfT2xPURxBs+VhjD6PNNL512urAoe3Wv8T0QZGq1V0efjqJPNxrp6ClJp6PLkl5ijFC0KaC12cx7EbnsAcwHmr7VSVUsFon80= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703841141; c=relaxed/simple; bh=du0kqcX9ORN+QLZLNVhyBaVuyllb/NcRkdsjJBA17Oo=; h=DKIM-Signature:Mime-Version:Subject:From:Date:Message-Id:To; b=pNR22KO/fssnZnM4SkJSwx7LH4N21fW+dkmHR49UWzUcG3S3aDrdt8U5udBDfjsW3ClJcv2BQIZoYoAlhBIQycseHpN+DL2qKbuPWJD6TtunC1yIuwyTEm7tMCoVnmSADxSA0Ruk0Mbjbmszy5U21x3VCe8Egp3DSwAHaH2ha1c= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-28bbe484bc0so1270972a91.1 for ; Fri, 29 Dec 2023 01:12:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703841133; x=1704445933; darn=sourceware.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MmfBEu9eIvABbL/jSkejVUaxLXOxG8CfqdD9qy8EsY8=; b=giueT5zXL+WUt84zcreHUOrNZVu6FeJxRYJIuC4F27886i1QsAVYd8+VW5Qo/FhT47 dQABzZy3Ly67D6I+44QoS9qfZH3xKHVJdirh+Y7jUM/3s/N3ZVr2WwpH+TsUQoPKW6zq t/NzV9PIGWC4uoI/haabxlRaZtuZgh9bG+XIyA2E5rQMwvqne1dHynzRmCSM1lSQmHay hw5CRYDy0jU/NK85Xs3uw03hF2/zlXBh7002904t+CTjM+OaoBM81KtwzCJHj4bfBvCS GsDcE3bI0jKBi6XFu+N4EvpfdwByKuHndz5kzBaFhh1ZoAfWycZvkvAhvGwgAHSL8VkO sBew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703841133; x=1704445933; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MmfBEu9eIvABbL/jSkejVUaxLXOxG8CfqdD9qy8EsY8=; b=C8Hk3l5PAAdh5OkzYoWHNNenRGiAe2asikhUPJVNpwoZvJBKyj3BwanFAZE4CpoC0j ciNbLB1UoL3vmKNvaZVL7eTnvSnFQ6kOq9xX/fg+iOffzpD/8s6MB8B2KUwFhcoeb5Z/ oBawr3aBJiOdTQ/B3jYRuMVIqA/ZcfxlnuuWSlSqxqKUSHZwd9EhTnX4S28uGIw0Lgb4 6YVw0yJqTsdjA8Qhl7jXWLnCWXYJLgPRjiqwQvs+tOPW5ryeEpat6FSMm8dSq0/YK2hA uqTLaAfzAUoguNQTXAPm2bKnerNbWQtbS6kphJqJ3Fpg4aJ7VJktxa/EjIjcqBop0Yqc 6RFg== X-Gm-Message-State: AOJu0YyhAwuLM1eapo9kSblQXUtsX72WfWRjPpXF8vpAD6XREiMLTgcX VJdyGs+jG1JDxzcyiguEZqvyBgiptiHi4BTS X-Google-Smtp-Source: AGHT+IHCNnW9oBg3WMCXt7bGW0O3pNxjEDHpKEEDk/rIxsbNjy7uFHIwornFeE8X+NBp/SbH5+FYdA== X-Received: by 2002:a05:6a20:3e0c:b0:196:1899:d758 with SMTP id m12-20020a056a203e0c00b001961899d758mr6313363pzc.1.1703841132998; Fri, 29 Dec 2023 01:12:12 -0800 (PST) Received: from smtpclient.apple (zz20184013906F627101.userreverse.dion.ne.jp. [111.98.113.1]) by smtp.gmail.com with ESMTPSA id y18-20020a17090abd1200b0028c465b050asm10383342pjr.54.2023.12.29.01.12.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Dec 2023 01:12:12 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.300.61.1.2\)) Subject: Re: [PATCH] LoongArch: Update comment about bottom bit usage in TLS GOT construction From: Tatsuyuki Ishi In-Reply-To: Date: Fri, 29 Dec 2023 18:11:56 +0900 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 Content-Transfer-Encoding: quoted-printable Message-Id: <2E548645-1BD7-4B21-B1D0-D5961A11FC0D@gmail.com> References: <20231228145802.74719-1-ishitatsuyuki@gmail.com> <20231228145802.74719-3-ishitatsuyuki@gmail.com> To: mengqinggang X-Mailer: Apple Mail (2.3774.300.61.1.2) X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,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: > On Dec 29, 2023, at 17:50, mengqinggang = wrote: >=20 > 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.=E2=80=9D). = Even at that time, there was no |=3D 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 =E2=80=9CAt the = beginning of implementation=E2=80=9D refer to? > =E5=9C=A8 2023/12/28 =E4=B8=8B=E5=8D=8810:58, Tatsuyuki Ishi =E5=86=99=E9= =81=93: >> 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(-) >>=20 >> 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 -=3D 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 |=3D 1 >> - make only one type be relocated. We must use >> - h->got.offset |=3D 1 and h->got.offset |=3D 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: >=20