From owner-freebsd-dtrace@FreeBSD.ORG Fri Jan 30 22:10:31 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 CEDBC681; Fri, 30 Jan 2015 22:10:31 +0000 (UTC) Received: from mail-pa0-x22c.google.com (mail-pa0-x22c.google.com [IPv6:2607:f8b0:400e:c03::22c]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 95F77EA7; Fri, 30 Jan 2015 22:10:31 +0000 (UTC) Received: by mail-pa0-f44.google.com with SMTP id rd3so57216623pab.3; Fri, 30 Jan 2015 14:10:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=AhS7PjxOgNlEORIrKxDDzFi99ea/mfNMlz76Ew/DkOo=; b=qGS1oGQ/36SuJSsvyF31EbM8tMbuzHpjl1TlmY31++VIRVL7QD/NNYckTYB7Ex+k8r qZx9Ac3QpwCbE74uwQkrJw3ScMaidJ+fDLBVq5F79NSmY/20vsNnHoYiL5RLU6fWS3Wh dBffSQcEXsU12kx9j2qONAITJMdoNZSAJruo/2L2xnJGXMrzQyV9qX171uDJycBwmYRt ghjlXIF1qDsemqB5VxDKDAr+faTLYVQeWP6kft7+Z+sdgMJY2dIaGAMU4jsJHKYIvsIq t31T5O29lKODgmua0rQRxPBQD+XTVKcg/P3wj/alJFt+FfyLxt0UFnq8XzB3GYl5A+WA UEvw== X-Received: by 10.66.194.102 with SMTP id hv6mr12171267pac.138.1422655830897; Fri, 30 Jan 2015 14:10:30 -0800 (PST) Received: from charmander.picturesperfect.net (c-67-182-131-225.hsd1.wa.comcast.net. [67.182.131.225]) by mx.google.com with ESMTPSA id mw3sm11766372pdb.30.2015.01.30.14.10.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jan 2015 14:10:29 -0800 (PST) Sender: Mark Johnston Date: Fri, 30 Jan 2015 14:10:24 -0800 From: Mark Johnston To: Ed Maste Subject: Re: removing USDT's libelf dependency Message-ID: <20150130221024.GA2731@charmander.picturesperfect.net> References: <20150130061355.GA14037@raichu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) 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 22:10:32 -0000 On Fri, Jan 30, 2015 at 10:15:09AM -0500, Ed Maste wrote: > On 30 January 2015 at 01:13, Mark Johnston wrote: > > > > 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. > > I'm not worried about issues with lld here - we can make it meet our > requirements. I am a little worried that there will be code floating > around that does strcmp(foo, ".SUNW_dof") though. A quick search > turned up some examples. Most are copies of drti.c but I did find one > case in some markjdb Github repo :-) Heh, oops. > Even if we don't end up changing > .SUNW_dof I think we should convert these cases to use the section > type instead of name. I agree. In the case of drti.c, we look for both the section type and name. There isn't much else out there that looks for a DOF section. > > We could give GNU ld 2.17.50 and lld knowledge of .SUNW_dof and > __SUNW_dof. This looks like it would be straightforward, but at the > cost of carrying around different FreeBSD-specific changes. > > I think our best approach will be to find an approach that upstream > linker projects (GNU ld, gold, lld) are willing to support. But, until > or unless that happens I'd much rather we switch to SUNW_dof than > require linking against libelf. Ok. It looks like gold also supports the __start_ feature from GNU ld; there's a thread about handling the case where starts with a period here: http://comments.gmane.org/gmane.comp.gnu.binutils/61852, though it didn't really go anywhere. lld doesn't support the feature AFAICS. For now I'd rather just change the section name. -Mark