From patchwork Thu Dec 28 14:58:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tatsuyuki Ishi X-Patchwork-Id: 183751 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2041856dyb; Thu, 28 Dec 2023 07:00:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXzltPm1eNTnbTHeVjdiOn0BpuWPXExO/EfZEMrMBZHnsqu4r000QSxr7na4lFRT7jUGw8 X-Received: by 2002:a67:ea8e:0:b0:466:f72b:e94a with SMTP id f14-20020a67ea8e000000b00466f72be94amr3915514vso.33.1703775630138; Thu, 28 Dec 2023 07:00:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703775630; cv=pass; d=google.com; s=arc-20160816; b=IQYqWuIctyrxgl75IYAKtRyUDYKdzg1wLjKfsJTLw7qfzS+7GwRC2hH+213Iw0mJjV JQLMul0ZML5CkoFcT+YTuX5IdsnBhrColuw+Lpgi7UWO7i/JLlEc6USL6A7LiW7rAv/6 yluk6TwdHegoDarb+7QjOPytsfnE1mZ/tnogZ316wFUbKL/R7CIsvx0p5SUFQpbh6rQI mc4r7FH2J0GfwvaAF1eF+exlzxluaz9rGLf5NYcO9Jl7A94B+38hNqWzyjHsCO7MLoDD o9gr26zks1LiE429vTN84dkFdIt0liWs67M/vBb0Dwu/eYJsHcFgOdYL8We4RSHLK/zl xS2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=wYHol1nBRdW6LwY+CCgzHX8CJTFjN/vlEy0SC/sVJrw=; fh=668u74SvSvArSqc7noKmensIZFIe0zihgHJnrvcGugg=; b=C5id4slFVnBt6rlFvvIV2RITZ03swVW/fcQQOiD+oq7IETj5i+zDup2ICEuX2706bs jkpp9x0s2UhGz26Avpt3w+dn23V5EMHsWZSeBgKl8sKY2tUIbQ8tAkvvBr71OoS/TRAl YWOjrbFtBDgUDt3wnAUKDgCGSmnLffdXLPSrc1UVR4rmVsJDvIjvVGEFg8QKvlS1vPgn hJehdvtrkFzJEolrgt1363tjpXk0FnrqfamCtIiZi1I1D8SdK6BrhqFCL9J4iX+Ntjkl x7/8sDp7exf+OULVWNYNJZUOyY7scllBdPU38BveGVZOGcQ+X0z/SMCWWesU7NIbPyA9 f2Mg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=EWiuPQYW; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id x5-20020ab035c5000000b007c3f210d50dsi2261974uat.144.2023.12.28.07.00.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 07:00:30 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=EWiuPQYW; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6FCAA3857729 for ; Thu, 28 Dec 2023 15:00:25 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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-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 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786538235138278008 X-GMAIL-MSGID: 1786538235138278008 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: