From: Andrew Jones <ajones@ventanamicro.com>
To: Samuel Holland <samuel.holland@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
Alexandre Ghiti <alex@ghiti.fr>,
linux-riscv@lists.infradead.org,
Pinkesh Vaghela <pinkesh.vaghela@einfochips.com>,
Pritesh Patel <pritesh.patel@einfochips.com>,
Darshan Prajapati <darshan.prajapati@einfochips.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Charlie Jenkins <charlie@rivosinc.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] riscv: module: Allocate PLT entries for R_RISCV_PLT32
Date: Wed, 9 Apr 2025 20:53:57 +0200 [thread overview]
Message-ID: <20250409-cf4fead4fda7b1b11bf4107d@orel> (raw)
In-Reply-To: <20250409171526.862481-2-samuel.holland@sifive.com>
On Wed, Apr 09, 2025 at 10:14:50AM -0700, Samuel Holland wrote:
> apply_r_riscv_plt32_rela() may need to emit a PLT entry for the
> referenced symbol, so there must be space allocated in the PLT.
>
> Fixes: 8fd6c5142395 ("riscv: Add remaining module relocations")
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
> ---
>
> Changes in v2:
> - New patch for v2
>
> arch/riscv/kernel/module-sections.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/arch/riscv/kernel/module-sections.c b/arch/riscv/kernel/module-sections.c
> index e264e59e596e..91d0b355ceef 100644
> --- a/arch/riscv/kernel/module-sections.c
> +++ b/arch/riscv/kernel/module-sections.c
> @@ -73,16 +73,17 @@ static bool duplicate_rela(const Elf_Rela *rela, int idx)
> static void count_max_entries(Elf_Rela *relas, int num,
> unsigned int *plts, unsigned int *gots)
> {
> - unsigned int type, i;
> -
> - for (i = 0; i < num; i++) {
> - type = ELF_RISCV_R_TYPE(relas[i].r_info);
> - if (type == R_RISCV_CALL_PLT) {
> + for (int i = 0; i < num; i++) {
> + switch (ELF_R_TYPE(relas[i].r_info)) {
I see ELF_R_TYPE() is equivalent to ELF_RISCV_R_TYPE(). So OK.
> + case R_RISCV_CALL_PLT:
> + case R_RISCV_PLT32:
> if (!duplicate_rela(relas, i))
> (*plts)++;
> - } else if (type == R_RISCV_GOT_HI20) {
> + break;
> + case R_RISCV_GOT_HI20:
> if (!duplicate_rela(relas, i))
> (*gots)++;
> + break;
> }
> }
> }
> --
> 2.47.0
>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Thanks,
drew
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-04-09 18:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 17:14 [PATCH v2 1/3] riscv: module: Fix out-of-bounds relocation access Samuel Holland
2025-04-09 17:14 ` [PATCH v2 2/3] riscv: module: Allocate PLT entries for R_RISCV_PLT32 Samuel Holland
2025-04-09 18:53 ` Andrew Jones [this message]
2025-04-09 17:14 ` [PATCH v2 3/3] riscv: module: Optimize PLT/GOT entry counting Samuel Holland
2025-04-09 19:07 ` Andrew Jones
2025-04-09 19:18 ` Samuel Holland
2025-04-09 19:24 ` Andrew Jones
2025-04-09 19:11 ` [PATCH v2 1/3] riscv: module: Fix out-of-bounds relocation access Maxim Kochetkov
2025-04-11 11:21 ` Alexandre Ghiti
2025-04-16 18:42 ` patchwork-bot+linux-riscv
2025-06-02 22:12 ` patchwork-bot+linux-riscv
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=20250409-cf4fead4fda7b1b11bf4107d@orel \
--to=ajones@ventanamicro.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=charlie@rivosinc.com \
--cc=darshan.prajapati@einfochips.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=pinkesh.vaghela@einfochips.com \
--cc=pritesh.patel@einfochips.com \
--cc=samuel.holland@sifive.com \
/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