From owner-freebsd-toolchain@FreeBSD.ORG Sun Feb 19 08:03:00 2012 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 75F1A106567A; Sun, 19 Feb 2012 08:03:00 +0000 (UTC) (envelope-from draco@marino.st) Received: from shepard.synsport.net (mail.synsport.com [208.69.230.148]) by mx1.freebsd.org (Postfix) with ESMTP id 4CD878FC0C; Sun, 19 Feb 2012 08:02:59 +0000 (UTC) Received: from [192.168.0.11] (atoulouse-256-1-26-95.w90-38.abo.wanadoo.fr [90.38.109.95]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by shepard.synsport.net (Postfix) with ESMTP id 89CCA438BD; Sun, 19 Feb 2012 02:02:58 -0600 (CST) Message-ID: <4F40ACB4.8000103@marino.st> Date: Sun, 19 Feb 2012 09:03:00 +0100 From: John Marino User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: Konstantin Belousov References: <4F3C5A3A.6050107@FreeBSD.org> <20120216154730.GL3283@deviant.kiev.zoral.com.ua> <4F3D3409.3040006@marino.st> <20120216202709.GQ3283@deviant.kiev.zoral.com.ua> <4F3F4AE2.30203@marino.st> <20120218213832.GL3283@deviant.kiev.zoral.com.ua> In-Reply-To: <20120218213832.GL3283@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kan@freebsd.org, Pedro Giffuni , freebsd-toolchain@freebsd.org Subject: Re: DragonFly added support for ELF preinit, init, and fini arrays X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Feb 2012 08:03:00 -0000 On 2/18/2012 10:38 PM, Konstantin Belousov wrote: > > Thank you, it was very useful. It seems that test4 needed some adjustments > to actually provide the required dso for tests. Yeah. I thought I gave you a version that worked out of the box but I did modify this test as well. > Now, the patch at http://people.freebsd.org/~kib/misc/init_array.2.patch > passes your tests and allows to boot world built with pre-patched csu > into multiuser mode. > > I decided to move the calls to initializers for main binary into rtld, > and used the brand note to distinguish old and new csu. I assume the purpose of this is to have a clean split with static initialization done in crt1 and dynamic initialization done entirely in rtld for binaries built with version 100009 and later. Does the note digestion used to check osrel add significant overhead? Is not this information already available via aux_vectors passed on from imgact_elf.c? > > ATM patch is only for i386 and amd64, I will port to other architectures > after some feedback. It's out of scope of your current work but related to notes, but there's another test that DragonFly passes that FreeBSD fails. If memory serves, it was caused by the PT_NOTE segment getting located outside of the first page the majority of the time starting with binutils 2.21. http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/9d35f29fb5dd669d4e04521b39296e5bdf14b2b0 A related problem was an interpret segment outside of the first page: http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/99aed3e43ef052664173110d6db3ddf6a62e375b Both of these were handled within sys/kern/imgact_elf.c John From owner-freebsd-toolchain@FreeBSD.ORG Sun Feb 19 18:26:53 2012 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA5C5106564A; Sun, 19 Feb 2012 18:26:53 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 0E21E8FC14; Sun, 19 Feb 2012 18:26:52 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q1JIQh5Z079942 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 19 Feb 2012 20:26:43 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q1JIQeBH050043; Sun, 19 Feb 2012 20:26:40 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q1JIQdPx050042; Sun, 19 Feb 2012 20:26:39 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 19 Feb 2012 20:26:39 +0200 From: Konstantin Belousov To: John Marino Message-ID: <20120219182639.GT3283@deviant.kiev.zoral.com.ua> References: <4F3C5A3A.6050107@FreeBSD.org> <20120216154730.GL3283@deviant.kiev.zoral.com.ua> <4F3D3409.3040006@marino.st> <20120216202709.GQ3283@deviant.kiev.zoral.com.ua> <4F3F4AE2.30203@marino.st> <20120218213832.GL3283@deviant.kiev.zoral.com.ua> <4F40ACB4.8000103@marino.st> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="38w/fdPQT2lDf/hx" Content-Disposition: inline In-Reply-To: <4F40ACB4.8000103@marino.st> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: kan@freebsd.org, Pedro Giffuni , freebsd-toolchain@freebsd.org Subject: Re: DragonFly added support for ELF preinit, init, and fini arrays X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Feb 2012 18:26:53 -0000 --38w/fdPQT2lDf/hx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Feb 19, 2012 at 09:03:00AM +0100, John Marino wrote: > On 2/18/2012 10:38 PM, Konstantin Belousov wrote: > > > >Thank you, it was very useful. It seems that test4 needed some adjustmen= ts > >to actually provide the required dso for tests. > Yeah. I thought I gave you a version that worked out of the box but I=20 > did modify this test as well. >=20 > >Now, the patch at http://people.freebsd.org/~kib/misc/init_array.2.patch > >passes your tests and allows to boot world built with pre-patched csu > >into multiuser mode. > > > >I decided to move the calls to initializers for main binary into rtld, > >and used the brand note to distinguish old and new csu. > I assume the purpose of this is to have a clean split with static=20 > initialization done in crt1 and dynamic initialization done entirely in= =20 > rtld for binaries built with version 100009 and later. Does the note=20 > digestion used to check osrel add significant overhead? I do not think that note parsing can add any measureable overhead. The goal there is not to have some theoretical cleaness, but to cause the least possible bug propagation. The crt code gets linked into the binary, be it static or dynamic. We cannot help the static case, but for dynamic one, less non-application code is stored in the binary, the bigger our possibilities to deliver fixes for OS bugs without requiring application recompilation. =46rom this POV, having the preinit array/init/array init linked into the binary is quite bad. >=20 > Is not this information already available via aux_vectors passed on from= =20 > imgact_elf.c? No. After thinking about the init_array.3 patch which uses __FreeBSD_version of the crt to distinguish old and new crt, I understood that this change is very hard to merge to stable branch. In essence, we would ship some rtld's in HEAD which will misbehave on stable binaries, if the change is merged back. So I decided to redo this once more, adding a vendor note that signifies that crt does not call init. See http://people.freebsd.org/~kib/misc/init_array.4.patch >=20 > > > >ATM patch is only for i386 and amd64, I will port to other architectures > >after some feedback. > It's out of scope of your current work but related to notes, but there's= =20 > another test that DragonFly passes that FreeBSD fails. If memory=20 > serves, it was caused by the PT_NOTE segment getting located outside of= =20 > the first page the majority of the time starting with binutils 2.21. > http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/9d35f29fb5dd669d4= e04521b39296e5bdf14b2b0 >=20 > A related problem was an interpret segment outside of the first page: > http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/99aed3e43ef052664= 173110d6db3ddf6a62e375b >=20 > Both of these were handled within sys/kern/imgact_elf.c The fact that interpreter path and notes should be placed at the first page of ELF image is well-known ELF quirk, possibly not well documented. There is indeed an issue with crtbrand.c unable to create a proper section for the note, see the long comment in recent crtbrand.c. FreeBSD solution was to emit right section type. --38w/fdPQT2lDf/hx Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk9BPt8ACgkQC3+MBN1Mb4hPTACeIC7dpWLAH3d+228GBL/kePcK qZUAn0GY6Tf/Imcidmx09FdCC8eQQ2iu =r5YQ -----END PGP SIGNATURE----- --38w/fdPQT2lDf/hx--