aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/link_elf.c
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2019-09-23 14:14:43 +0000
committerMark Johnston <markj@FreeBSD.org>2019-09-23 14:14:43 +0000
commit38dae42c26d630cdbd2184ad13a45c021d87e1f7 (patch)
treeff4d4f3f13753ad60c160987cfe0ae2db0672528 /sys/kern/link_elf.c
parent751727948a2924c8ae424e81d9cd7aff9d8dd4d3 (diff)
downloadsrc-38dae42c26d630cdbd2184ad13a45c021d87e1f7.tar.gz
src-38dae42c26d630cdbd2184ad13a45c021d87e1f7.zip
Use elf_relocaddr() when handling R_X86_64_RELATIVE relocations.
This is required for DPCPU and VNET data variable definitions to work when KLDs are linked as DSOs. R_X86_64_RELATIVE relocations should not appear in object files, so assert this in elf_relocaddr(). Reviewed by: kib MFC after: 1 month Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D21755
Notes
Notes: svn path=/head/; revision=352623
Diffstat (limited to 'sys/kern/link_elf.c')
-rw-r--r--sys/kern/link_elf.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
index 8d07dd5bbb7c..80b2656d8d27 100644
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
@@ -1162,6 +1162,9 @@ elf_relocaddr(linker_file_t lf, Elf_Addr x)
{
elf_file_t ef;
+ KASSERT(lf->ops->cls == (kobj_class_t)&link_elf_class,
+ ("elf_relocaddr: unexpected linker file %p", lf));
+
ef = (elf_file_t)lf;
if (x >= ef->pcpu_start && x < ef->pcpu_stop)
return ((x - ef->pcpu_start) + ef->pcpu_base);