public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nelson Chu <nelson@rivosinc.com>
To: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
Cc: binutils@sourceware.org, i@maskray.me, rui314@gmail.com,
	 ruiu@bluewhale.systems
Subject: Re: [PATCH v3 4/9] RISC-V: Define and use GOT entry size constants for TLS.
Date: Mon, 19 Feb 2024 09:57:39 +0800	[thread overview]
Message-ID: <CAPpQWtAKVhQ3+3GE16GGZfaZ7YLFeoADmrrbWa7GkecVD8FCkA@mail.gmail.com> (raw)
In-Reply-To: <20231128085109.28422-5-ishitatsuyuki@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4213 bytes --]

Okay, but probably need to update the code since commit 20ef84ed2abb.
Otherwise this patch looks good to me.

Thanks
Nelson

On Tue, Nov 28, 2023 at 4:51 PM Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
wrote:

> 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: Add macros for sizes of a normal GOT entry, TLS GD and
>     TLS IE entry.
>     (allocate_dynrelocs): Replace GOT size expressions with the new
>     constants.
>     (riscv_elf_size_dynamic_sections): Likewise.
>     (riscv_elf_relocate_section): Likewise.
> ---
>  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 c0207765906..d5190538503 100644
> --- a/bfd/elfnn-riscv.c
> +++ b/bfd/elfnn-riscv.c
> @@ -298,6 +298,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?  */
> @@ -1320,7 +1322,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);
>             }
> @@ -1328,14 +1330,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);
> @@ -1563,20 +1565,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);
>                 }
> @@ -2912,7 +2914,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.43.0
>
>

  reply	other threads:[~2024-02-19  1:57 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 18:08 [PATCH 0/4] RISC-V: Implement TLS Descriptors Tatsuyuki Ishi
2023-08-17 18:08 ` [PATCH 1/4] RISC-V: Add TLSDESC reloc definitions Tatsuyuki Ishi
2023-08-17 18:08 ` [PATCH 2/4] RISC-V: Add assembly support for TLSDESC Tatsuyuki Ishi
2023-08-17 18:08 ` [PATCH 3/4] RISC-V: Define and use GOT entry size constants for TLS Tatsuyuki Ishi
2023-08-17 18:08 ` [PATCH 4/4] RISC-V: Initial ld.bfd support for TLSDESC Tatsuyuki Ishi
2023-08-18  0:22 ` [PATCH 0/4] RISC-V: Implement TLS Descriptors Nelson Chu
2023-08-18  7:13   ` Fangrui Song
2023-08-31 17:13 ` [PATCH v2 0/5] " Tatsuyuki Ishi
2023-08-31 17:13   ` [PATCH v2 1/5] RISC-V: Fix local GOT and reloc size calculation for TLS Tatsuyuki Ishi
2024-02-21  0:49     ` Nelson Chu
2024-02-21  7:04       ` Nelson Chu
2023-08-31 17:13   ` [PATCH v2 2/5] RISC-V: Add TLSDESC reloc definitions Tatsuyuki Ishi
2023-08-31 17:13   ` [PATCH v2 3/5] RISC-V: Add assembly support for TLSDESC Tatsuyuki Ishi
2023-08-31 17:13   ` [PATCH v2 4/5] RISC-V: Define and use GOT entry size constants for TLS Tatsuyuki Ishi
2023-08-31 17:13   ` [PATCH v2 5/5] RISC-V: Initial ld.bfd support for TLSDESC Tatsuyuki Ishi
2023-11-28  8:51 ` [PATCH v3 0/9] RISC-V: Implement TLS Descriptors Tatsuyuki Ishi
2023-11-28  8:51   ` [PATCH v3 1/9] RISC-V: Fix local GOT and reloc size calculation for TLS Tatsuyuki Ishi
2023-11-28  8:51   ` [PATCH v3 2/9] RISC-V: Add TLSDESC reloc definitions Tatsuyuki Ishi
2024-02-19  0:49     ` Nelson Chu
2024-02-20 17:28       ` Tatsuyuki Ishi
2023-11-28  8:51   ` [PATCH v3 3/9] RISC-V: Add assembly support for TLSDESC Tatsuyuki Ishi
2024-02-19  1:44     ` Nelson Chu
2024-02-20 17:29       ` Tatsuyuki Ishi
2023-11-28  8:51   ` [PATCH v3 4/9] RISC-V: Define and use GOT entry size constants for TLS Tatsuyuki Ishi
2024-02-19  1:57     ` Nelson Chu [this message]
2024-02-20 17:32       ` Tatsuyuki Ishi
2023-11-28  8:51   ` [PATCH v3 5/9] RISC-V: Initial ld.bfd support for TLSDESC Tatsuyuki Ishi
2024-02-19  4:33     ` Nelson Chu
2024-02-20 17:36       ` Tatsuyuki Ishi
2023-11-28  8:51   ` [PATCH v3 6/9] RISC-V: Move STATIC_TLS handling into record_tls_type Tatsuyuki Ishi
2023-11-28  8:51   ` [PATCH v3 7/9] RISC-V: Unify TLS handling in check_relocs Tatsuyuki Ishi
2023-11-28  8:51   ` [PATCH v3 8/9] RISC-V: Add elf_link_hash_entry to relax_func args Tatsuyuki Ishi
2023-11-28  8:51   ` [PATCH v3 9/9] RISC-V: Introduce TLSDESC relaxation Tatsuyuki Ishi
2023-12-05 16:44   ` [PATCH v3 0/9] RISC-V: Implement TLS Descriptors Tatsuyuki Ishi
2023-12-06  0:33     ` Nelson Chu
2023-12-07  3:35       ` Fangrui Song
2023-12-13  0:27         ` Palmer Dabbelt
2023-12-13  1:53           ` Tatsuyuki Ishi
2024-01-27  0:57             ` Fangrui Song
2024-02-20 17:55 ` [PATCH v4 " Tatsuyuki Ishi
2024-02-20 17:55   ` [PATCH v4 1/9] RISC-V: Fix local GOT and reloc size calculation for TLS Tatsuyuki Ishi
2024-02-20 17:55   ` [PATCH v4 2/9] RISC-V: Add TLSDESC reloc definitions Tatsuyuki Ishi
2024-02-20 17:55   ` [PATCH v4 3/9] RISC-V: Add assembly support for TLSDESC Tatsuyuki Ishi
2024-02-20 17:55   ` [PATCH v4 4/9] RISC-V: Define and use GOT entry size constants for TLS Tatsuyuki Ishi
2024-02-20 17:55   ` [PATCH v4 5/9] RISC-V: Initial ld.bfd support for TLSDESC Tatsuyuki Ishi
2024-02-20 17:55   ` [PATCH v4 6/9] RISC-V: Move STATIC_TLS handling into record_tls_type Tatsuyuki Ishi
2024-02-20 17:55   ` [PATCH v4 7/9] RISC-V: Unify TLS handling in check_relocs Tatsuyuki Ishi
2024-02-20 17:55   ` [PATCH v4 8/9] RISC-V: Add elf_link_hash_entry to relax_func args Tatsuyuki Ishi
2024-02-20 17:55   ` [PATCH v4 9/9] RISC-V: Introduce TLSDESC relaxation Tatsuyuki Ishi
2024-02-29  7:06   ` [PATCH v4 0/9] RISC-V: Implement TLS Descriptors Nelson Chu
2024-02-29  7:14     ` Tatsuyuki Ishi
2024-03-29  6:22       ` Tatsuyuki Ishi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPpQWtAKVhQ3+3GE16GGZfaZ7YLFeoADmrrbWa7GkecVD8FCkA@mail.gmail.com \
    --to=nelson@rivosinc.com \
    --cc=binutils@sourceware.org \
    --cc=i@maskray.me \
    --cc=ishitatsuyuki@gmail.com \
    --cc=rui314@gmail.com \
    --cc=ruiu@bluewhale.systems \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).