git: fc4c39c54fc2 - main - kldxref: handle R_RISCV_64 relocation
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 20 Oct 2022 15:04:28 UTC
The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=fc4c39c54fc240af424ae249b75057d2977ef8f2 commit fc4c39c54fc240af424ae249b75057d2977ef8f2 Author: Mitchell Horne <mhorne@FreeBSD.org> AuthorDate: 2022-10-20 14:56:01 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2022-10-20 15:01:29 +0000 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 --- usr.sbin/kldxref/ef_riscv.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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);