diff --git a/usr.sbin/kldxref/ef_riscv.c b/usr.sbin/kldxref/ef_riscv.c index e0caae3bd286..b94b37b3a92f 100644 --- a/usr.sbin/kldxref/ef_riscv.c +++ b/usr.sbin/kldxref/ef_riscv.c @@ -45,10 +45,10 @@ int ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase, Elf_Off dataoff, size_t len, void *dest) { - Elf_Addr *where, val; + Elf_Addr *where; const Elf_Rela *rela; Elf_Addr addend, addr; - Elf_Size rtype; + Elf_Size rtype, symidx; switch (reltype) { case EF_RELOC_RELA: @@ -57,6 +57,7 @@ ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase, dataoff); addend = rela->r_addend; rtype = ELF_R_TYPE(rela->r_info); + symidx = ELF_R_SYM(rela->r_info); break; default: return (EINVAL); @@ -66,10 +67,13 @@ ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase, return (0); switch (rtype) { + case R_RISCV_64: /* S + A */ + addr = EF_SYMADDR(ef, symidx) + addend; + *where = addr; + break; case R_RISCV_RELATIVE: /* B + A */ addr = addend + relbase; - val = addr; - *where = val; + *where = addr; break; default: warnx("unhandled relocation type %d", (int)rtype);