Date: Sat, 3 Feb 2018 01:23:49 +0000 (UTC) From: Ed Maste <emaste@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328826 - head/stand/common Message-ID: <201802030123.w131Nnpm035213@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802030123.w131Nnpm035213>