riscv: fix relocation handling for R_RISCV_64

It requires the addend. In practice this doesn't seem to be a problem,
since relocations of this type are all with an addend of zero.
Obviously, we still want to handle this correctly if that ever changes.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37039
This commit is contained in:
Mitchell Horne 2022-10-20 11:56:59 -03:00
parent fc4c39c54f
commit a9b24e4dc2

View File

@ -340,15 +340,25 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
break;
case R_RISCV_64:
error = lookup(lf, symidx, 1, &addr);
if (error != 0)
return (-1);
before64 = *where;
*where = addr + addend;
if (debug_kld)
printf("%p %c %-24s %016lx -> %016lx\n", where,
(local ? 'l' : 'g'), reloctype_to_str(rtype),
before64, *where);
break;
case R_RISCV_JUMP_SLOT:
error = lookup(lf, symidx, 1, &addr);
if (error != 0)
return (-1);
val = addr;
before64 = *where;
if (*where != val)
*where = val;
*where = addr;
if (debug_kld)
printf("%p %c %-24s %016lx -> %016lx\n", where,
(local ? 'l' : 'g'), reloctype_to_str(rtype),