From owner-freebsd-ppc@freebsd.org Wed Oct 31 14:33:57 2018 Return-Path: Delivered-To: freebsd-ppc@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 B60AB10DBB91 for ; Wed, 31 Oct 2018 14:33:57 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic316-13.consmr.mail.bf2.yahoo.com (sonic316-13.consmr.mail.bf2.yahoo.com [74.6.130.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5E07A78475 for ; Wed, 31 Oct 2018 14:33:57 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: bk3iBIoVM1mOSFtR6k9MSDaOBbOwzfOU1aQFeXNp0t37IAv6UuzcldWWXWfgYoe _DFuExack1Z0l2uDow1qRfqL1ybiZfJJUm9lk.wtEAjB41YiRW4xQSNHuL8sT7zTDXPGLIkY1uYE k.DGw1sHoMpRK0genWvw84jBu9aYesHinE7ZN7NsZ_F0ga9hIXk1eFDeBL4YcpYXcItc_RSrKdmv cNh6TNS0mCIbp4Y4uen.vjzhtPWRxXEi28S9xPm_Xh9quT02Mzvfaz7CCVGQACb9UimfipLTar.Y .Iwc_p4wKkACjoJnVZ8ZJojvcrzgqPiM8Ol3eJEQskBefIox_iojIfs5d7hexlWQZuxoE0SJNsEJ kYO2okcrbfwoSu1St9QrZolImZsc7x7VFZ4gqrD0IVM4twp77CTtKfuwgurPPMWA2TKSrrFIRCYK QbxD2meTZlQWN3lbjgPu5_.B2.gqcmvE80c38dMTeJ2X.ofeJsr.RMF6uN4IkLqjRBT.PyFYhGXy kFg6urGoPE2uzuwPfTVbom018Y15ahA_2VhJ8k8sVqXXm6a1HVkMEF7ccUEQlFWCmVmtl4z_YsD4 mkIoWDv8xdwwPmRWBVnZNIGHYZngzXhWmrzaEkeUp9RXrJCAdJy0sKB.as9H2yKGJmAH0AM8szX9 .8_EDVs0ZLB.pGkYLutolaOrHTyUHAo3m_OLNk1VLGPTkvvzOWVFjLitpzQhgUwbGb7RuMCusffb XZWkA3ONyFUremNEyBPFazLbhnjY5ECBZZuiMIWxJ8SCcCNiaXokpQY_XNlqMjxI.hP49zMVfP9I 7bYtU_5WIOhMzfZTWhG2MpsqbJJsuc_iTheNQPgaB0oPSQx5KX_mLj8wsf_yUf64cY3j.5c8ECut RpMbieBNlyDF16zHn.QxQcVc5iaYfD9Y1lMU7UVzVor4XlsTZlapR7ZrFwo56OSMtk9eb5QD8DKg dm9yJArCVqk7zSksVThoogJQXVEBsJPmEZEogUgP1Mycn_Z7S1cDcnn9W7BRz70mgswL.5m.Pv6I 4aAdiYot62xhyKwsT76JunXhBi1y7C26Sj8_UInZRKthWHe3B Received: from sonic.gate.mail.ne1.yahoo.com by sonic316.consmr.mail.bf2.yahoo.com with HTTP; Wed, 31 Oct 2018 14:33:50 +0000 Received: from c-76-115-7-162.hsd1.or.comcast.net (EHLO [192.168.1.25]) ([76.115.7.162]) by smtp411.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID ef9889f0fc3040597a601d70ce8d459e; Wed, 31 Oct 2018 14:33:46 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: svn commit: r339876 - head/libexec/rtld-elf From: Mark Millard In-Reply-To: Date: Wed, 31 Oct 2018 07:33:43 -0700 Cc: FreeBSD PowerPC ML Content-Transfer-Encoding: quoted-printable Message-Id: <77371AC1-C422-47A6-9EA5-9A92F958D86B@yahoo.com> References: To: Michael Tuexen X-Mailer: Apple Mail (2.3445.9.1) X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Oct 2018 14:33:57 -0000 On 2018-Oct-30, at 3:59 AM, Michael Tuexen = wrote: > FYI >=20 >> Begin forwarded message: >>=20 >> From: Michael Tuexen >> Subject: Re: svn commit: r339876 - head/libexec/rtld-elf >> Date: 30. October 2018 at 11:17:39 CET >> To: Alex Richardson >> Cc: src-committers , = svn-src-all@freebsd.org, svn-src-head@freebsd.org >>=20 >>> On 29. Oct 2018, at 22:08, Alex Richardson = wrote: >>>=20 >>> Author: arichardson >>> Date: Mon Oct 29 21:08:02 2018 >>> New Revision: 339876 >>> URL: https://svnweb.freebsd.org/changeset/base/339876 >>>=20 >>> Log: >>> rtld: set obj->textsize correctly >>>=20 >>> With lld-generated binaries the first PT_LOAD will usually be a = read-only >>> segment unless you pass --no-rosegment. For those binaries the = textsize is >>> determined by the next PT_LOAD. To allow both LLD and bfd 2.17 = binaries to >>> be parsed correctly use the end of the last PT_LOAD that is marked = as >>> executable instead. >>>=20 >>> I noticed that the value was wrong while adding some debug prints = for some rtld >>> changes for CHERI binaries. `obj->textsize` only seems to be used by = PPC so the >>> effect is untested. However, the value before was definitely wrong = and the new >>> result matches the phdrs. >> I build kernel and world with a revision later than this on a PPC. Which have you tried: 32 bit? 64 bit? Both? If both, do both fail? What version did the buildworld buildkernel ? What version was built by the buildworld buildkernel (that was later installed and had failures)? Do you know what version did the prior buildworld buildkernel (that produced the version that did this buildworld buildkernel)? If yes, what was it? >> Buildword >> ends up with a world where almost all binaries are segfaulting.... = Especially gdb >> (but svn, ls or so all segfault). Which fail: /usr/local/bin/gdb ? /usr/libexec/gdb ? Both? /usr/local/bin/svn ? /usr/bin/svnlite ? Both? /bin/ls ? /rescue/ls ? Both? That last may be the more important comparison. >>=20 >> Best regards >> Michael >>>=20 >>> Reviewed By: kib >>> Approved By: brooks (mentor) >>> Differential Revision: https://reviews.freebsd.org/D17117 >>>=20 >>> Modified: >>> head/libexec/rtld-elf/map_object.c >>> head/libexec/rtld-elf/rtld.c >>>=20 >>> Modified: head/libexec/rtld-elf/map_object.c >>> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >>> --- head/libexec/rtld-elf/map_object.c Mon Oct 29 21:03:43 2018 = (r339875) >>> +++ head/libexec/rtld-elf/map_object.c Mon Oct 29 21:08:02 2018 = (r339876) >>> @@ -93,6 +93,7 @@ map_object(int fd, const char *path, const struct = stat >>> Elf_Addr note_end; >>> char *note_map; >>> size_t note_map_len; >>> + Elf_Addr text_end; >>>=20 >>> hdr =3D get_elf_header(fd, path, sb); >>> if (hdr =3D=3D NULL) >>> @@ -116,6 +117,7 @@ map_object(int fd, const char *path, const = struct stat >>> note_map =3D NULL; >>> segs =3D alloca(sizeof(segs[0]) * hdr->e_phnum); >>> stack_flags =3D RTLD_DEFAULT_STACK_PF_EXEC | PF_R | PF_W; >>> + text_end =3D 0; >>> while (phdr < phlimit) { >>> switch (phdr->p_type) { >>>=20 >>> @@ -130,6 +132,10 @@ map_object(int fd, const char *path, const = struct stat >>> path, nsegs); >>> goto error; >>> } >>> + if ((segs[nsegs]->p_flags & PF_X) =3D=3D PF_X) { >>> + text_end =3D MAX(text_end, >>> + round_page(segs[nsegs]->p_vaddr + = segs[nsegs]->p_memsz)); >>> + } >>> break; >>>=20 >>> case PT_PHDR: >>> @@ -280,8 +286,7 @@ map_object(int fd, const char *path, const = struct stat >>> } >>> obj->mapbase =3D mapbase; >>> obj->mapsize =3D mapsize; >>> - obj->textsize =3D round_page(segs[0]->p_vaddr + = segs[0]->p_memsz) - >>> - base_vaddr; >>> + obj->textsize =3D text_end - base_vaddr; >>> obj->vaddrbase =3D base_vaddr; >>> obj->relocbase =3D mapbase - base_vaddr; >>> obj->dynamic =3D (const Elf_Dyn *) (obj->relocbase + = phdyn->p_vaddr); >>>=20 >>> Modified: head/libexec/rtld-elf/rtld.c >>> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >>> --- head/libexec/rtld-elf/rtld.c Mon Oct 29 21:03:43 2018 = (r339875) >>> +++ head/libexec/rtld-elf/rtld.c Mon Oct 29 21:08:02 2018 = (r339876) >>> @@ -1390,13 +1390,15 @@ digest_phdr(const Elf_Phdr *phdr, int phnum, = caddr_t e >>> if (nsegs =3D=3D 0) { /* First load segment */ >>> obj->vaddrbase =3D trunc_page(ph->p_vaddr); >>> obj->mapbase =3D obj->vaddrbase + obj->relocbase; >>> - obj->textsize =3D round_page(ph->p_vaddr + ph->p_memsz) = - >>> - obj->vaddrbase; >>> } else { /* Last load segment */ >>> obj->mapsize =3D round_page(ph->p_vaddr + ph->p_memsz) - >>> obj->vaddrbase; >>> } >>> nsegs++; >>> + if ((ph->p_flags & PF_X) =3D=3D PF_X) { >>> + obj->textsize =3D MAX(obj->textsize, >>> + round_page(ph->p_vaddr + ph->p_memsz) - = obj->vaddrbase); >>> + } >>> break; >>>=20 >>> case PT_DYNAMIC: >>>=20 >>=20 >>=20 >=20 =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)