git: aaba1490ec4b - main - kldxref: Implement aarch64 R_AARCH64_AB64 relocation

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Thu, 14 Dec 2023 20:18:16 UTC
The branch main has been updated by jrtc27:

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

commit aaba1490ec4b17dea750b1e58dfded7aeb4e9816
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2023-12-14 20:17:20 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2023-12-14 20:17:20 +0000

    kldxref: Implement aarch64 R_AARCH64_AB64 relocation
    
    Doing nothing seems to be sufficient but is strange, inconsistent with
    other architectures, and not necessary when it's easy to support
    properly.
---
 usr.sbin/kldxref/ef_aarch64.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/kldxref/ef_aarch64.c b/usr.sbin/kldxref/ef_aarch64.c
index f1e499e76ef1..4365a7ff1f66 100644
--- a/usr.sbin/kldxref/ef_aarch64.c
+++ b/usr.sbin/kldxref/ef_aarch64.c
@@ -43,8 +43,8 @@ ef_aarch64_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
     GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
 {
 	char *where;
-	Elf64_Addr addend;
-	GElf_Size rtype;
+	GElf_Addr addr, addend;
+	GElf_Size rtype, symidx;
 	const GElf_Rela *rela;
 
 	if (reltype != ELF_T_RELA)
@@ -54,6 +54,7 @@ ef_aarch64_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
 	where = (char *)dest - dataoff + rela->r_offset;
 	addend = rela->r_addend;
 	rtype = GELF_R_TYPE(rela->r_info);
+	symidx = GELF_R_SYM(rela->r_info);
 
 	if (where < (char *)dest || where >= (char *)dest + len)
 		return (0);
@@ -63,6 +64,8 @@ ef_aarch64_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
 		le64enc(where, relbase + addend);
 		break;
 	case R_AARCH64_ABS64:
+		addr = EF_SYMADDR(ef, symidx) + addend;
+		le64enc(where, addr);
 		break;
 	default:
 		warnx("unhandled relocation type %d", (int)rtype);