aboutsummaryrefslogtreecommitdiff
path: root/stand/common
diff options
context:
space:
mode:
authorD Scott Phillips <scottph@FreeBSD.org>2020-09-21 22:24:46 +0000
committerD Scott Phillips <scottph@FreeBSD.org>2020-09-21 22:24:46 +0000
commit987eabdc2ae1c0beba77e4d3b538155e81c7a7d5 (patch)
tree1694131ed36d07d1f050c12e8411ff1e50f8c9f8 /stand/common
parentde031846985c46cf6bbc709bbfa5dfa81541d2b6 (diff)
downloadsrc-987eabdc2ae1c0beba77e4d3b538155e81c7a7d5.tar.gz
src-987eabdc2ae1c0beba77e4d3b538155e81c7a7d5.zip
stand/reloc_elf: Handle relative relocations for arm{,64} and riscv
Extend the powerpc relative relocation handling from r240782 to a handful of other architectures. This is needed to properly read dependency information from kernel modules. Reviewed by: jhb Approved by: scottl (implicit) MFC after: 1 week Sponsored by: Ampere Computing, Inc. Differential Revision: https://reviews.freebsd.org/D26365
Notes
Notes: svn path=/head/; revision=365982
Diffstat (limited to 'stand/common')
-rw-r--r--stand/common/reloc_elf.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/stand/common/reloc_elf.c b/stand/common/reloc_elf.c
index 8e15cd0152e5..f8417aeeb64a 100644
--- a/stand/common/reloc_elf.c
+++ b/stand/common/reloc_elf.c
@@ -175,7 +175,8 @@ __elfN(reloc)(struct elf_file *ef, symaddr_fn *symaddr, const void *reldata,
}
return (0);
-#elif defined(__powerpc__)
+#elif defined(__aarch64__) || defined(__arm__) || defined(__powerpc__) || \
+ defined(__riscv)
Elf_Size w;
const Elf_Rela *rela;
@@ -185,7 +186,15 @@ __elfN(reloc)(struct elf_file *ef, symaddr_fn *symaddr, const void *reldata,
if (relbase + rela->r_offset >= dataaddr &&
relbase + rela->r_offset < dataaddr + len) {
switch (ELF_R_TYPE(rela->r_info)) {
+#if defined(__aarch64__)
+ case R_AARCH64_RELATIVE:
+#elif defined(__arm__)
+ case R_ARM_RELATIVE:
+#elif defined(__powerpc__)
case R_PPC_RELATIVE:
+#elif defined(__riscv)
+ case R_RISCV_RELATIVE:
+#endif
w = relbase + rela->r_addend;
bcopy(&w, (u_char *)data + (relbase +
rela->r_offset - dataaddr), sizeof(w));