From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 28 11:03:31 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CDF7C106566B for ; Tue, 28 Aug 2012 11:03:31 +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 478188FC08 for ; Tue, 28 Aug 2012 11:03:30 +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 q7SB3Z05001497; Tue, 28 Aug 2012 14:03:35 +0300 (EEST) (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 q7SB3N33064684; Tue, 28 Aug 2012 14:03:23 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q7SB3MpU064683; Tue, 28 Aug 2012 14:03:22 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 28 Aug 2012 14:03:22 +0300 From: Konstantin Belousov To: Jilles Tjoelker Message-ID: <20120828110322.GJ33100@deviant.kiev.zoral.com.ua> References: <20120824221655.GA76607@stack.nl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="o1/0/m+AY5DY8EuM" Content-Disposition: inline In-Reply-To: <20120824221655.GA76607@stack.nl> 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=-4.0 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: freebsd-hackers@freebsd.org Subject: Re: [patch] libc: Do not export .cerror X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Aug 2012 11:03:31 -0000 --o1/0/m+AY5DY8EuM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Aug 25, 2012 at 12:16:55AM +0200, Jilles Tjoelker wrote: > For some reason, libc exports the symbol .cerror (HIDENAME(cerror)), > albeit in the FBSDprivate_1.0 version. It looks like there is no reason > for this since it is not used from other libraries. Given that it cannot > be accessed from C and its strange calling convention, it is rather > unlikely that other things rely on it. Perhaps it is from a time when > symbols could not be hidden.=20 Probably, the idea was that the symbol can be interposed. Not sure who wanted such functionality. >=20 > Not exporting .cerror causes it to be jumped to directly instead of via > the PLT. >=20 > The below patch is for i386 only and also takes advantage of .cerror's > new status by not saving and loading %ebx before jumping to it. > (Therefore, .cerror now saves and loads %ebx itself.) Where there was a > conditional jump to a jump to .cerror, the conditional jump has been > changed to jump to .cerror directly (many modern CPUs don't do static > prediction and in any case it is not much of a benefit anyway). Why do you need to save/restore the %ebx at all ? %ebx =3D=3D &__GLOBAL_OFFSET_TABLE__ is only needed when you access GOT, but .cerror only works with PLT, which is addressed using the instruction capable of relative addressing. The old .cerror does not need it as well, but it is just engraved in the function ABI. >=20 > The patch decreases the size of libc.so.7 by a few kilobytes. >=20 > Similar changes could be made to other architectures, and there may be > more symbols that are exported but need not be. Sure, would you handle at least amd64 too ? --o1/0/m+AY5DY8EuM Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlA8pXoACgkQC3+MBN1Mb4g4agCfVD+hxac270WlKmbGCVnmgtzA bE0AnilyIRW6+t6MVzmA0DPVVVjvoeZ8 =HuxN -----END PGP SIGNATURE----- --o1/0/m+AY5DY8EuM--