From owner-svn-src-all@freebsd.org Wed Mar 18 02:58:21 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BA6C727A50D; Wed, 18 Mar 2020 02:58:21 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48hvqd2nKXz4CZX; Wed, 18 Mar 2020 02:58:21 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F02401B56C; Wed, 18 Mar 2020 02:58:20 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02I2wKO9049411; Wed, 18 Mar 2020 02:58:20 GMT (envelope-from bdragon@FreeBSD.org) Received: (from bdragon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02I2wI3G049399; Wed, 18 Mar 2020 02:58:18 GMT (envelope-from bdragon@FreeBSD.org) Message-Id: <202003180258.02I2wI3G049399@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdragon set sender to bdragon@FreeBSD.org using -f From: Brandon Bergren Date: Wed, 18 Mar 2020 02:58:18 +0000 (UTC) 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 X-SVN-Group: head X-SVN-Commit-Author: bdragon X-SVN-Commit-Paths: in head/sys: amd64/amd64 arm/arm arm64/arm64 i386/i386 kern mips/mips powerpc/powerpc riscv/riscv sys X-SVN-Commit-Revision: 359062 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 02:58:21 -0000 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