Date: Wed, 18 Mar 2020 02:58:18 +0000 (UTC) From: Brandon Bergren <bdragon@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r359062 - in head/sys: amd64/amd64 arm/arm arm64/arm64 i386/i386 kern mips/mips powerpc/powerpc riscv/riscv sys Message-ID: <202003180258.02I2wI3G049399@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bdragon Date: Wed Mar 18 02:58:18 2020 New Revision: 359062 URL: https://svnweb.freebsd.org/changeset/base/359062 Log: [PowerPC][Book-E] Fix missing load base in elf_cpu_parse_dynamic(). When I implemented MD DYNAMIC parsing, I was originally passing a linker_file_t so that the MD code could relocate pointers. However, it turns out this isn't even filled in until later, so it was always 0. Just pass the load base (ef->address) directly, as that's really the only thing we were interested in in the first place. This fixes a crash on RB800 where it was trying to write to an unmapped address when updating the GOT. Reviewed by: jhibbits Sponsored by: Tag1 Consulting, Inc. Differential Revision: https://reviews.freebsd.org/D24105 Modified: head/sys/amd64/amd64/elf_machdep.c head/sys/arm/arm/elf_machdep.c head/sys/arm64/arm64/elf_machdep.c head/sys/i386/i386/elf_machdep.c head/sys/kern/link_elf.c head/sys/mips/mips/elf_machdep.c head/sys/powerpc/powerpc/elf32_machdep.c head/sys/powerpc/powerpc/elf64_machdep.c head/sys/riscv/riscv/elf_machdep.c head/sys/sys/linker.h Modified: head/sys/amd64/amd64/elf_machdep.c ============================================================================== --- head/sys/amd64/amd64/elf_machdep.c Wed Mar 18 02:20:03 2020 (r359061) +++ head/sys/amd64/amd64/elf_machdep.c Wed Mar 18 02:58:18 2020 (r359062) @@ -331,7 +331,7 @@ elf_cpu_unload_file(linker_file_t lf __unused) } int -elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused) +elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused) { return (0); Modified: head/sys/arm/arm/elf_machdep.c ============================================================================== --- head/sys/arm/arm/elf_machdep.c Wed Mar 18 02:20:03 2020 (r359061) +++ head/sys/arm/arm/elf_machdep.c Wed Mar 18 02:58:18 2020 (r359062) @@ -327,7 +327,7 @@ elf_cpu_load_file(linker_file_t lf) } int -elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused) +elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused) { return (0); Modified: head/sys/arm64/arm64/elf_machdep.c ============================================================================== --- head/sys/arm64/arm64/elf_machdep.c Wed Mar 18 02:20:03 2020 (r359061) +++ head/sys/arm64/arm64/elf_machdep.c Wed Mar 18 02:58:18 2020 (r359062) @@ -258,7 +258,7 @@ elf_cpu_unload_file(linker_file_t lf __unused) } int -elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused) +elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused) { return (0); Modified: head/sys/i386/i386/elf_machdep.c ============================================================================== --- head/sys/i386/i386/elf_machdep.c Wed Mar 18 02:20:03 2020 (r359061) +++ head/sys/i386/i386/elf_machdep.c Wed Mar 18 02:58:18 2020 (r359062) @@ -297,7 +297,7 @@ elf_cpu_unload_file(linker_file_t lf __unused) } int -elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused) +elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused) { return (0); Modified: head/sys/kern/link_elf.c ============================================================================== --- head/sys/kern/link_elf.c Wed Mar 18 02:20:03 2020 (r359061) +++ head/sys/kern/link_elf.c Wed Mar 18 02:58:18 2020 (r359062) @@ -620,7 +620,7 @@ parse_dynamic(elf_file_t ef) ef->ddbstrtab = ef->strtab; ef->ddbstrcnt = ef->strsz; - return elf_cpu_parse_dynamic(&ef->lf, ef->dynamic); + return elf_cpu_parse_dynamic(ef->address, ef->dynamic); } #define LS_PADDING 0x90909090 Modified: head/sys/mips/mips/elf_machdep.c ============================================================================== --- head/sys/mips/mips/elf_machdep.c Wed Mar 18 02:20:03 2020 (r359061) +++ head/sys/mips/mips/elf_machdep.c Wed Mar 18 02:58:18 2020 (r359062) @@ -503,7 +503,7 @@ elf_cpu_unload_file(linker_file_t lf __unused) } int -elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused) +elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused) { return (0); Modified: head/sys/powerpc/powerpc/elf32_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/elf32_machdep.c Wed Mar 18 02:20:03 2020 (r359061) +++ head/sys/powerpc/powerpc/elf32_machdep.c Wed Mar 18 02:58:18 2020 (r359062) @@ -403,7 +403,7 @@ ppc32_runtime_resolve() } int -elf_cpu_parse_dynamic(linker_file_t lf, Elf_Dyn *dynamic) +elf_cpu_parse_dynamic(caddr_t loadbase, Elf_Dyn *dynamic) { Elf_Dyn *dp; bool has_plt = false; @@ -414,7 +414,7 @@ elf_cpu_parse_dynamic(linker_file_t lf, Elf_Dyn *dynam switch (dp->d_tag) { case DT_PPC_GOT: secure_plt = true; - got = (Elf_Addr *)(lf->address + dp->d_un.d_ptr); + got = (Elf_Addr *)(loadbase + dp->d_un.d_ptr); /* Install runtime resolver canary. */ got[1] = (Elf_Addr)ppc32_runtime_resolve; got[2] = (Elf_Addr)0; Modified: head/sys/powerpc/powerpc/elf64_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/elf64_machdep.c Wed Mar 18 02:20:03 2020 (r359061) +++ head/sys/powerpc/powerpc/elf64_machdep.c Wed Mar 18 02:58:18 2020 (r359062) @@ -416,7 +416,7 @@ elf_cpu_unload_file(linker_file_t lf __unused) } int -elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused) +elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused) { return (0); Modified: head/sys/riscv/riscv/elf_machdep.c ============================================================================== --- head/sys/riscv/riscv/elf_machdep.c Wed Mar 18 02:20:03 2020 (r359061) +++ head/sys/riscv/riscv/elf_machdep.c Wed Mar 18 02:58:18 2020 (r359062) @@ -506,7 +506,7 @@ elf_cpu_unload_file(linker_file_t lf __unused) } int -elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused) +elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused) { return (0); Modified: head/sys/sys/linker.h ============================================================================== --- head/sys/sys/linker.h Wed Mar 18 02:20:03 2020 (r359061) +++ head/sys/sys/linker.h Wed Mar 18 02:58:18 2020 (r359062) @@ -305,7 +305,7 @@ int linker_ctf_get(linker_file_t, linker_ctf_t *); int elf_cpu_load_file(linker_file_t); int elf_cpu_unload_file(linker_file_t); -int elf_cpu_parse_dynamic(linker_file_t, Elf_Dyn *); +int elf_cpu_parse_dynamic(caddr_t, Elf_Dyn *); /* values for type */ #define ELF_RELOC_REL 1
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202003180258.02I2wI3G049399>