svn commit: r353924 - in stable/12/sys: amd64/amd64 kern
Mark Johnston
markj at FreeBSD.org
Wed Oct 23 13:41:59 UTC 2019
Author: markj
Date: Wed Oct 23 13:41:58 2019
New Revision: 353924
URL: https://svnweb.freebsd.org/changeset/base/353924
Log:
MFC r352623:
Use elf_relocaddr() when handling R_X86_64_RELATIVE relocations.
Modified:
stable/12/sys/amd64/amd64/elf_machdep.c
stable/12/sys/kern/link_elf.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/amd64/amd64/elf_machdep.c
==============================================================================
--- stable/12/sys/amd64/amd64/elf_machdep.c Wed Oct 23 13:41:44 2019 (r353923)
+++ stable/12/sys/amd64/amd64/elf_machdep.c Wed Oct 23 13:41:58 2019 (r353924)
@@ -268,7 +268,6 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas
*/
printf("kldload: unexpected R_COPY relocation\n");
return (-1);
- break;
case R_X86_64_GLOB_DAT: /* S */
case R_X86_64_JMP_SLOT: /* XXX need addend + offset */
@@ -280,7 +279,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas
break;
case R_X86_64_RELATIVE: /* B + A */
- addr = relocbase + addend;
+ addr = elf_relocaddr(lf, relocbase + addend);
val = addr;
if (*where != val)
*where = val;
Modified: stable/12/sys/kern/link_elf.c
==============================================================================
--- stable/12/sys/kern/link_elf.c Wed Oct 23 13:41:44 2019 (r353923)
+++ stable/12/sys/kern/link_elf.c Wed Oct 23 13:41:58 2019 (r353924)
@@ -1163,6 +1163,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);
More information about the svn-src-all
mailing list