From owner-svn-src-all@freebsd.org Sat Feb 3 01:23:49 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9FB25EDAC85; Sat, 3 Feb 2018 01:23:49 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4EDCB6AC0A; Sat, 3 Feb 2018 01:23:49 +0000 (UTC) (envelope-from emaste@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 49CBD2397D; Sat, 3 Feb 2018 01:23:49 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w131NniU035214; Sat, 3 Feb 2018 01:23:49 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w131Nnpm035213; Sat, 3 Feb 2018 01:23:49 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201802030123.w131Nnpm035213@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sat, 3 Feb 2018 01:23:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328826 - head/stand/common X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/stand/common X-SVN-Commit-Revision: 328826 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.25 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: Sat, 03 Feb 2018 01:23:49 -0000 Author: emaste Date: Sat Feb 3 01:23:48 2018 New Revision: 328826 URL: https://svnweb.freebsd.org/changeset/base/328826 Log: Make cross-endian loader changes apply only to powerpc The cross-endian loader change in r328536 (review D12422) broke symbol loading on (at least) amd64 kernels. Temporarily paper over the issue by restricting the cross-endian support to only powerpc, until a proper fix arrives. Submitted by: royger Modified: head/stand/common/load_elf.c Modified: head/stand/common/load_elf.c ============================================================================== --- head/stand/common/load_elf.c Sat Feb 3 01:20:01 2018 (r328825) +++ head/stand/common/load_elf.c Sat Feb 3 01:23:48 2018 (r328826) @@ -127,7 +127,10 @@ __elfN(load_elf_header)(char *filename, elf_file_t ef) goto error; } +#ifdef __powerpc__ /* + * XXX: should be in a separate helper. + * * Fixup ELF endianness. * * The Xhdr structure was loaded using block read call to @@ -179,6 +182,7 @@ __elfN(load_elf_header)(char *filename, elf_file_t ef) ehdr->e_shnum = le16toh(ehdr->e_shnum); ehdr->e_shstrndx = le16toh(ehdr->e_shstrndx); } +#endif if (ehdr->e_version != EV_CURRENT || ehdr->e_machine != ELF_TARG_MACH) { /* Machine ? */ err = EFTYPE; @@ -375,15 +379,6 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_ u_int fpcopy; Elf_Sym sym; Elf_Addr p_start, p_end; -#if __ELF_WORD_SIZE == 64 - uint64_t scr_ssym; - uint64_t scr_esym; - uint64_t scr; -#else - uint32_t scr_ssym; - uint32_t scr_esym; - uint32_t scr; -#endif dp = NULL; shdr = NULL; @@ -458,7 +453,10 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_ phdr = (Elf_Phdr *)(ef->firstpage + ehdr->e_phoff); for (i = 0; i < ehdr->e_phnum; i++) { +#ifdef __powerpc__ /* + * XXX: should be in a seprate helper. + * * Fixup ELF endianness. * * The Xhdr structure was loaded using block read call to @@ -505,6 +503,7 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_ phdr[i].p_align = le32toh(phdr[i].p_align); } } +#endif /* We want to load PT_LOAD segments only.. */ if (phdr[i].p_type != PT_LOAD) @@ -581,7 +580,10 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_ goto nosyms; } +#ifdef __powerpc__ /* + * XXX: should be in a seprate helper. + * * Fixup ELF endianness. * * The Xhdr structure was loaded using block read call to @@ -634,6 +636,8 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_ } } } +#endif + file_addmetadata(fp, MODINFOMD_SHDR, chunk, shdr); /* @@ -712,16 +716,15 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_ size = shdr[i].sh_size; #if defined(__powerpc__) #if __ELF_WORD_SIZE == 64 - scr = htobe64(size); + size = htobe64(size); #else - scr = htobe32(size); + size = htobe32(size); #endif -#else - scr = size; #endif - archsw.arch_copyin(&scr, lastaddr, sizeof(scr)); - lastaddr += sizeof(scr); + archsw.arch_copyin(&size, lastaddr, sizeof(size)); + lastaddr += sizeof(size); + #ifdef ELF_VERBOSE printf("\n%s: 0x%jx@0x%jx -> 0x%jx-0x%jx", secname, (uintmax_t)shdr[i].sh_size, (uintmax_t)shdr[i].sh_offset, @@ -762,19 +765,16 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_ #if defined(__powerpc__) /* On PowerPC we always need to provide BE data to the kernel */ #if __ELF_WORD_SIZE == 64 - scr_ssym = htobe64((uint64_t)ssym); - scr_esym = htobe64((uint64_t)esym); + ssym = htobe64((uint64_t)ssym); + esym = htobe64((uint64_t)esym); #else - scr_ssym = htobe32((uint32_t)ssym); - scr_esym = htobe32((uint32_t)esym); + ssym = htobe32((uint32_t)ssym); + esym = htobe32((uint32_t)esym); #endif -#else - scr_ssym = ssym; - scr_esym = esym; #endif - file_addmetadata(fp, MODINFOMD_SSYM, sizeof(scr_ssym), &scr_ssym); - file_addmetadata(fp, MODINFOMD_ESYM, sizeof(scr_esym), &scr_esym); + file_addmetadata(fp, MODINFOMD_SSYM, sizeof(ssym), &ssym); + file_addmetadata(fp, MODINFOMD_ESYM, sizeof(esym), &esym); nosyms: printf("\n");