From owner-freebsd-dtrace@FreeBSD.ORG Fri Jan 30 10:36:39 2015 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 81D439F7; Fri, 30 Jan 2015 10:36:39 +0000 (UTC) Received: from vps.hungerhost.com (vps.hungerhost.com [216.38.53.176]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5C05D5EE; Fri, 30 Jan 2015 10:36:39 +0000 (UTC) Received: from [81.168.91.50] (port=53407 helo=[172.16.19.1]) by vps.hungerhost.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82) (envelope-from ) id 1YH8wB-0001Bl-PP; Fri, 30 Jan 2015 05:36:32 -0500 From: "George Neville-Neil" To: "Mark Johnston" Subject: Re: removing USDT's libelf dependency Date: Fri, 30 Jan 2015 10:36:19 +0000 Message-ID: In-Reply-To: <20150130061355.GA14037@raichu> References: <20150130061355.GA14037@raichu> MIME-Version: 1.0 X-Mailer: MailMate (1.8r5035) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vps.hungerhost.com X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - neville-neil.com X-Get-Message-Sender-Via: vps.hungerhost.com: authenticated_id: gnn@neville-neil.com Cc: freebsd-dtrace@freebsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jan 2015 10:36:39 -0000 On 30 Jan 2015, at 6:13, Mark Johnston wrote: > Hello, > > At the moment, any FreeBSD program containing USDT probes needs to be > linked with libelf. This is so that drti.o can find the address of the > DOF section within the executable or library. With this, it can extract > the DOF and load it into the kernel prior to beginning execution. > > This requirement is an annoyance since it's specific to FreeBSD and > many upstream projects which support DTrace aren't aware of it, so some > patching is necessary to get their probes working on FreeBSD. It also > increases the startup cost of programs containing USDT probes, which can > be significant for e.g. sh(1) or libc/libthr (plockstat). > > Solaris exploits a feature of its linker to solve this problem - the > dtrace -G step emits an object file containing a symbol called > __SUNW_dof; the linker knows to fill in the value of this symbol with > the address of the DOF section, so drti.o begins execution with the DOF > section already available. > > It turns out that GNU ld implements a similar feature, albeit in a more > restrictive manner: a symbol named __start_ will have its value > filled in with the address of the section named . The catch is that > has to be a valid C identifier, and the DOF section is > conventionally named ".SUNW_dof", which of course doesn't quite work. I > propose using "SUNW_dof" instead so that we can make use of this linker > feature and eliminate the libelf dependency. > > DOF sections have their own ELF section type (SHT_SUNW_dof), so > anything that might want to find a DOF section should already be > searching for that rather than the conventional name. Depending on this > linker feature is also arguably a portability concern given that lld is > on the horizon, but we depend on it already anyway - this feature is > used in FreeBSD's linker set implementation (which in turn is used by > our SDT code :). So I don't think this would introduce a new problem. > > Any thoughts? > Do it. I can't see a problem thus far. Best, George