From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 049FA385DC02 for ; Thu, 17 Aug 2023 18:09:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 049FA385DC02 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1bdf1abee23so137615ad.0 for ; Thu, 17 Aug 2023 11:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692295764; x=1692900564; 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=/wIKW/ubIEfaUsGWQZdx94TLSSG26xKVZ4fCtDwJboQ=; b=LtZMYGFtZ0ol1KEcdaaHKKjxVNynfwlqBtzVCx2GwB7IIK6W2ns5Ciq3KRjkwh9AXa 82LRoYzY3/f4kNnzBfKrcXGGOXCuP/QjxCaf7mpYpLzblQUbVFcFgb6YU0XhEDvfNXPO 426YYZWPxqDHd4gy8fTNicAJS1c1uRDcgYxXdFZ2c7Ay2VV+DklzaPPmVNsJuf2GOhJ/ /XsvnljZHkYomBdjAOy2QtC8uG8wcEZgV51GSGyHztdELoAmzYjFWyiD1I7/iURRmrvY GzZTsx7ZWWLBGcHYpLKZKxMmGpQZY73YBpectVH7mtWx9TXfUWYG7Tv/UlAYfMa6erDX FHvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692295764; x=1692900564; 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=/wIKW/ubIEfaUsGWQZdx94TLSSG26xKVZ4fCtDwJboQ=; b=kLgTF29eFLgudOuNKvY5or/UBNZA+eistmiFh/oauLwWyWM7UrsDpuWJk1vNgQXuuh LtIVyTZ8NqBLyTRm/mgFUKoVN6lx8vK5O+MIo//W0zCmW4jcCkxPYHFO05K8g2wZWTBD fLYfRemNM73wi7jSyrmS4Lg9NNlkWHfWeEJD69ON1dORNwsBWOu0z/pLZtC/Jp6nPc2v Quq1LkeczvoN8rFpIzX03Nq12h117nkEtL1lCuDFGe7RIOr5BRXDdoIBiFx2qKZA9nTN Qg2l5jRTJ4tzw7gy38iOxWt/0CQwZCPUTMNOXn2//FEejs7DIJJOXJfiZ4JF6E7HIR8F QiPg== X-Gm-Message-State: AOJu0Yw7JQOUEF5zKncf9akeK62ff/0bsbpKwD7XEupdNEOBdeVjXKXh IeL+9wXtK0K4U+sNu81SacS1GfqgoeRJ+GZz X-Google-Smtp-Source: AGHT+IGx9EbNf2ILB7m8eBdL9Mx1LwQbg9/3n7chODXAxAAptuR0T/RXyY4oACvH4bKkqvWo4UguOg== X-Received: by 2002:a17:902:da88:b0:1bc:496c:8eda with SMTP id j8-20020a170902da8800b001bc496c8edamr132014plx.4.1692295764414; Thu, 17 Aug 2023 11:09:24 -0700 (PDT) Received: from localhost (zz20184013906F627101.userreverse.dion.ne.jp. [111.98.113.1]) by smtp.gmail.com with ESMTPSA id q18-20020a170902dad200b001b892aac5c9sm50318plx.298.2023.08.17.11.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 11:09:23 -0700 (PDT) From: Tatsuyuki Ishi To: binutils@sourceware.org Cc: rui314@gmail.com, ruiu@bluewhale.systems, Tatsuyuki Ishi Subject: [PATCH 3/4] RISC-V: Define and use GOT entry size constants for TLS. Date: Fri, 18 Aug 2023 03:08:36 +0900 Message-ID: <20230817180852.121628-5-ishitatsuyuki@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230817180852.121628-2-ishitatsuyuki@gmail.com> References: <20230817180852.121628-2-ishitatsuyuki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.5 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 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: As the size calculation is split by global and local symbols, using a shared constant definition for its size improves clarity. --- bfd/elfnn-riscv.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 02b46835cc7..38883134828 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -301,6 +301,8 @@ riscv_is_insn_reloc (const reloc_howto_type *howto) #define PLT_HEADER_SIZE (PLT_HEADER_INSNS * 4) #define PLT_ENTRY_SIZE (PLT_ENTRY_INSNS * 4) #define GOT_ENTRY_SIZE RISCV_ELF_WORD_BYTES +#define TLS_GD_GOT_ENTRY_SIZE (RISCV_ELF_WORD_BYTES * 2) +#define TLS_IE_GOT_ENTRY_SIZE RISCV_ELF_WORD_BYTES /* Reserve two entries of GOTPLT for ld.so, one is used for PLT resolver, the other is used for link map. Other targets also reserve one more entry used for runtime profile? */ @@ -1323,7 +1325,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* TLS_GD needs two dynamic relocs and two GOT slots. */ if (tls_type & GOT_TLS_GD) { - s->size += 2 * RISCV_ELF_WORD_BYTES; + s->size += TLS_GD_GOT_ENTRY_SIZE; if (need_reloc) htab->elf.srelgot->size += 2 * sizeof (ElfNN_External_Rela); } @@ -1331,14 +1333,14 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* TLS_IE needs one dynamic reloc and one GOT slot. */ if (tls_type & GOT_TLS_IE) { - s->size += RISCV_ELF_WORD_BYTES; + s->size += TLS_IE_GOT_ENTRY_SIZE; if (need_reloc) htab->elf.srelgot->size += sizeof (ElfNN_External_Rela); } } else { - s->size += RISCV_ELF_WORD_BYTES; + s->size += GOT_ENTRY_SIZE; if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h) && ! UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)) htab->elf.srelgot->size += sizeof (ElfNN_External_Rela); @@ -1566,20 +1568,20 @@ riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) { if (*local_tls_type & GOT_TLS_GD) { - s->size += 2 * RISCV_ELF_WORD_BYTES; + s->size += TLS_GD_GOT_ENTRY_SIZE; if (bfd_link_dll (info)) srel->size += sizeof (ElfNN_External_Rela); } if (*local_tls_type & GOT_TLS_IE) { - s->size += RISCV_ELF_WORD_BYTES; + s->size += TLS_IE_GOT_ENTRY_SIZE; if (bfd_link_dll (info)) srel->size += sizeof (ElfNN_External_Rela); } } else { - s->size += RISCV_ELF_WORD_BYTES; + s->size += GOT_ENTRY_SIZE; if (bfd_link_pic (info)) srel->size += sizeof (ElfNN_External_Rela); } @@ -2905,7 +2907,7 @@ riscv_elf_relocate_section (bfd *output_bfd, reference's GOT slot follows the GD reference's slots. */ ie_off = 0; if ((tls_type & GOT_TLS_GD) && (tls_type & GOT_TLS_IE)) - ie_off = 2 * GOT_ENTRY_SIZE; + ie_off = TLS_GD_GOT_ENTRY_SIZE; if ((off & 1) != 0) off &= ~1; -- 2.41.0