From owner-freebsd-arch@FreeBSD.ORG Fri Jan 18 04:31:41 2013 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 84C6032F for ; Fri, 18 Jan 2013 04:31:41 +0000 (UTC) (envelope-from stevek@juniper.net) Received: from exprod7og119.obsmtp.com (exprod7og119.obsmtp.com [64.18.2.16]) by mx1.freebsd.org (Postfix) with ESMTP id 7ADDFB43 for ; Fri, 18 Jan 2013 04:31:39 +0000 (UTC) Received: from P-EMHUB03-HQ.jnpr.net ([66.129.224.36]) (using TLSv1) by exprod7ob119.postini.com ([64.18.6.12]) with SMTP ID DSNKUPjQKvIaaPT/iVZuyceTaBXyTlQ7IEGm@postini.com; Thu, 17 Jan 2013 20:31:41 PST Received: from stevek-ubuntu (172.25.4.212) by P-EMHUB03-HQ.jnpr.net (172.24.192.33) with Microsoft SMTP Server id 8.3.213.0; Thu, 17 Jan 2013 20:29:29 -0800 Date: Thu, 17 Jan 2013 23:28:50 -0500 From: Steve Kiernan To: Konstantin Belousov Subject: Re: [JNPR] Proposal to add weak symbols for malloc, realloc, and free to libc Message-ID: <20130117232850.1b69bfc0@stevek-ubuntu> In-Reply-To: <20130118040933.GU2522@kib.kiev.ua> References: <20130117161311.4c15c7c4@stevek-ubuntu> <20130117184654.06f8e330@stevek-ubuntu> <20130118040933.GU2522@kib.kiev.ua> Organization: Juniper Networks Inc. X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.10; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/jHzI=xLs.qM.JOupZjVFARd"; protocol="application/pgp-signature" Cc: Jason Evans , freebsd-arch@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2013 04:31:41 -0000 --Sig_/jHzI=xLs.qM.JOupZjVFARd Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Fri, 18 Jan 2013 06:09:33 +0200 Konstantin Belousov wrote: > On Thu, Jan 17, 2013 at 06:46:54PM -0500, Steve Kiernan wrote: > > On Thu, 17 Jan 2013 15:42:19 -0800 > > Jason Evans wrote: > >=20 > > > On Jan 17, 2013, at 1:13 PM, Steve Kiernan wrote: > > > > When libc was changed to use jemalloc, the weak symbols for malloc,= realloc, and free ended up being removed. > > > > This makes it a bit difficult for an application to replace (or aug= ment) the malloc implementation. > > > >=20 > > > > This proposal is to add back the weak symbols similar to how they e= xisted in libc prior to jemalloc introduction. > > > >=20 > > > > See the following patch for the changes: > > > > http://people.freebsd.org/~marcel/Juniper/weak-malloc.diff > > > >=20 > > > > I'm not sure if the the symbols are in the proper place in the Symb= ol.map file and would welcome comments. > > >=20 > > > What about calloc(), posix_memalign(), and malloc_usable_size()? Sim= ilarly, I think the *allocm() functions in -current may need the same treat= ment. > >=20 > > I think you are correct and those would probably be necessary, as well,= yes. > >=20 > > It looked like previously, calloc was not made weak because it was impl= emented in terms of malloc, but since that is not the case in jemalloc, it = will need to be addressed. > >=20 > > I'll update the patch. >=20 > New symbols should be added to the current version, which is FBSD_1.3 > for the 10.0. Okay, great. Thank you for the information. > That said, what are the difficulties you experiencing with the malloc > interposing ? According to the normal ELF symbol lookup rules, the > definitions from any object which is loaded before libc overrides the > libc symbols. The problem is when one want to augment the calls. For example, say you want to do some leak detection or keep track of statistics that the malloc library does not. One would need to still call the original call after replacing the malloc/realloc/free/etc. with their own. Without having the __malloc/__realloc/__free/etc. that _used_ to be in libc, one cannot do so. -- Stephen J. Kiernan Juniper Networks, Inc. stevek_at_juniper.net --Sig_/jHzI=xLs.qM.JOupZjVFARd Content-Type: application/pgp-signature; name="signature.asc" Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAlD4z4MACgkQZSuJlLuTi6gMXgCfYq5jgkm/Mymg0BA/WbTmUeZ0 w7cAoLpNsm7xBH8YUZz4bq5nMRR0gayK =vB/z -----END PGP SIGNATURE----- --Sig_/jHzI=xLs.qM.JOupZjVFARd--