From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id CD0CE38582A8 for ; Thu, 28 Dec 2023 14:58:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD0CE38582A8 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 CD0CE38582A8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::633 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703775494; cv=none; b=YBJ97IPRGIHFvwKtXckgDHYC6VqyzrNklwg0zwLZuSEBpEcmFw3p2dMMEVUWzjRDbEAEb30jcomurm+NN7tpPA0f4POGXBVjyFZ7HrswnRHBk9fsgC+PTUcVrucubrxy8VNKsJpPdR61kDAgG9qMxYmpvNod2fz8j1mz+Scg7DY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703775494; c=relaxed/simple; bh=3RmGLoyo2i4gqIeLSCIRWtnVf/AiVTUGxuFUkFJW8h0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=iSjrCtP5q/4kIbIOaxpEgDyhfhfXQqPiyvRs48e99Ccjha+bYRSwO/mvhZIia7BY2YX2K9/pdlaiNmkWoOAQ5DtO/WtSHDvvoW7KmXfof6UpX+b0bma2q3cgj/VcksTGGQoPlWVZZXLnTm5XZJwy/nzTnV4fJMqSlHfwrsRiTs0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d3efb6bfa3so14119505ad.0 for ; Thu, 28 Dec 2023 06:58:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703775491; x=1704380291; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wYHol1nBRdW6LwY+CCgzHX8CJTFjN/vlEy0SC/sVJrw=; b=EWiuPQYWouI4MPjRZd8bZoP61F+EPa46ikZv0n4OPYqPmIvvYOvC35/Hx+rbcna4W7 gko7WsBU3damg8V3fvmumjLKkRPO4mBueyCNkCNJ5m72G+0HlSBAFI2AdZTEjEP2ospi tokBiFxzboMledD0bHDMelkkv1fJBlPemplq6/4C+PEmHZlYKqmP5/z6aJXly1PSa4yC 1ggwKhl9qiW6ikgxyKBMInEW1ASaXZrYX7S8NBGZ9tXbc9fAgNuU+Q8bnrZmPw7dKGiF Gevm/cf8sikW7ooJxOAT08JuYWROZ6UD3AFesejQ11YakS69qu6+svRmuErgAxXrRcaR R9sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703775491; x=1704380291; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wYHol1nBRdW6LwY+CCgzHX8CJTFjN/vlEy0SC/sVJrw=; b=Q7Ef+9AMKjudxKujodtL4za483gxQPQ6PY5KZimb315VjoSG1JYhtUi0vPXaV+L0NJ XdJePLUrMtGV07yEQSWSruiSgRZK5bwx3KOOYmL2I7/Z8C1txspKOKvhgl/abm5QD5ka faoPANAlmMgr6o3di2Yk80x6uhSiLrgLr0lJ3g7Dpf3EDHscFi0YE/yMjGqWaa9gPLlf LjtBTUfUpgbQ2+d46yDI9dPROAQ6OHpn/4CX7xgtYPiiVQ/1O2FdwONWMojYMI+qACKp zKKHuFERG7m6zc25tJkVxeCQWC7P1JO9cDI/jLSw0GHkyfTh9C7y6cAblhR+ZUyFkBjJ M3Lg== X-Gm-Message-State: AOJu0YxZeNbjqcXb8g+vFpZInVMU0MLw069Fs5YJqnI73kcH5EsM2mX1 y0nXGkfkRLUWrPVVows1kVTxSL3bwHALYo88 X-Google-Smtp-Source: AGHT+IFMhbMPzywzaTtzPi8Prn4txDpeP7PCYRgEFJKAojrcUkNoeRaESrh7vxEs4SWikIL3rat19w== X-Received: by 2002:a17:902:e5c6:b0:1d4:3238:37cb with SMTP id u6-20020a170902e5c600b001d4323837cbmr17430536plf.6.1703775490594; Thu, 28 Dec 2023 06:58:10 -0800 (PST) Received: from localhost (zz20184013906F627101.userreverse.dion.ne.jp. [111.98.113.1]) by smtp.gmail.com with ESMTPSA id jb2-20020a170903258200b001d3f790e0dbsm14070328plb.36.2023.12.28.06.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 06:58:10 -0800 (PST) From: Tatsuyuki Ishi To: binutils@sourceware.org Cc: cailulu@loongson.cn, chenglulu@loongson.cn, hejinyang@loongson.cn, i.swmail@xen0n.name, liuzhensong@loongson.cn, luweining@loongson.cn, maskray@google.com, mengqinggang@loongson.cn, nickc@redhat.com, wanglei@loongson.cn, xry111@xry111.site, xuchenghua@loongson.cn, Tatsuyuki Ishi Subject: [PATCH] LoongArch: Update comment about bottom bit usage in TLS GOT construction Date: Thu, 28 Dec 2023 23:58:02 +0900 Message-ID: <20231228145802.74719-3-ishitatsuyuki@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231228145802.74719-1-ishitatsuyuki@gmail.com> References: <20231228145802.74719-1-ishitatsuyuki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 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: 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: -- 2.40.1