Skip to content

Commit 1ee1313

Browse files
SiFiveHollandAlexandre Ghiti
authored andcommitted
riscv: module: Allocate PLT entries for R_RISCV_PLT32
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: 8fd6c51 ("riscv: Add remaining module relocations") Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Link: https://lore.kernel.org/r/20250409171526.862481-2-samuel.holland@sifive.com Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
1 parent 0b4cce6 commit 1ee1313

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

arch/riscv/kernel/module-sections.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,17 @@ static bool duplicate_rela(const Elf_Rela *rela, int idx)
7373
static void count_max_entries(Elf_Rela *relas, int num,
7474
unsigned int *plts, unsigned int *gots)
7575
{
76-
unsigned int type, i;
77-
78-
for (i = 0; i < num; i++) {
79-
type = ELF_RISCV_R_TYPE(relas[i].r_info);
80-
if (type == R_RISCV_CALL_PLT) {
76+
for (int i = 0; i < num; i++) {
77+
switch (ELF_R_TYPE(relas[i].r_info)) {
78+
case R_RISCV_CALL_PLT:
79+
case R_RISCV_PLT32:
8180
if (!duplicate_rela(relas, i))
8281
(*plts)++;
83-
} else if (type == R_RISCV_GOT_HI20) {
82+
break;
83+
case R_RISCV_GOT_HI20:
8484
if (!duplicate_rela(relas, i))
8585
(*gots)++;
86+
break;
8687
}
8788
}
8889
}

0 commit comments

Comments
 (0)