git: 04d4de5e609a - stable/13 - kldxref: add R_PPC64_ADDR64 handler

From: Alfredo Dal'Ava Junior <alfredo_at_FreeBSD.org>
Date: Mon, 07 Feb 2022 19:42:26 UTC
The branch stable/13 has been updated by alfredo:

URL: https://cgit.FreeBSD.org/src/commit/?id=04d4de5e609ab32892c68882db7e9b0f2cc1935d

commit 04d4de5e609ab32892c68882db7e9b0f2cc1935d
Author:     Alfredo Dal'Ava Junior <alfredo@FreeBSD.org>
AuthorDate: 2021-12-27 18:29:50 +0000
Commit:     Alfredo Dal'Ava Junior <alfredo@FreeBSD.org>
CommitDate: 2022-02-07 22:42:16 +0000

    kldxref: add R_PPC64_ADDR64 handler
    
    Implements R_PPC64_ADDR64 handler for kldxref, addressing
    "kldxref: unhandled relocation type 38" when running
    "kldxref /boot/kernel"
    
    Reviewed by:    jhibbits
    MFC after:      1 week
    Sponsored by:   Instituto de Pesquisas Eldorado (eldorado.org.br)
    Differential Revision:  https://reviews.freebsd.org/D33615
    
    (cherry picked from commit c3d9c63329a8b70a0a3b139c7819ace13aab6716)
---
 usr.sbin/kldxref/ef_powerpc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/kldxref/ef_powerpc.c b/usr.sbin/kldxref/ef_powerpc.c
index 4bb2792e0ecf..c50f518f892e 100644
--- a/usr.sbin/kldxref/ef_powerpc.c
+++ b/usr.sbin/kldxref/ef_powerpc.c
@@ -55,7 +55,7 @@ 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, addend;
-	Elf_Size rtype;
+	Elf_Size rtype, symidx;
 	const Elf_Rela *rela;
 
 	if (reltype != EF_RELOC_RELA)
@@ -65,6 +65,7 @@ ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase,
 	where = (Elf_Addr *) ((Elf_Off)dest - dataoff + rela->r_offset);
 	addend = rela->r_addend;
 	rtype = ELF_R_TYPE(rela->r_info);
+	symidx = ELF_R_SYM(rela->r_info);
 
 	if ((char *)where < (char *)dest || (char *)where >= (char *)dest + len)
 		return (0);
@@ -73,6 +74,9 @@ ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase,
 	case R_PPC_RELATIVE: /* word32|doubleword64 B + A */
 		*where = relbase + addend;
 		break;
+	case R_PPC64_ADDR64:	/* S + A */
+		*where = EF_SYMADDR(ef, symidx) + addend;
+		break;
 	default:
 		warnx("unhandled relocation type %" PRI_ELF_SIZE, rtype);
 	}