kldxref: handle R_RISCV_64 relocation

These are emitted in at least two kmods, and kldxref prints a warning.
While here, remove the unneeded local variable 'val'.

Reviewed by:	jrtc27, imp, emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37038
This commit is contained in:
Mitchell Horne 2022-10-20 11:56:01 -03:00
parent 330acb1883
commit fc4c39c54f

View File

@ -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);