Date: Fri, 30 Jan 2015 10:15:09 -0500 From: Ed Maste <emaste@freebsd.org> To: Mark Johnston <markj@freebsd.org> Cc: freebsd-dtrace@freebsd.org Subject: Re: removing USDT's libelf dependency Message-ID: <CAPyFy2CzUKNrzX=s6p6nBDVs=oYbztJya=bU54WhBi34k4XvgQ@mail.gmail.com> In-Reply-To: <20150130061355.GA14037@raichu> References: <20150130061355.GA14037@raichu>
next in thread | previous in thread | raw e-mail | index | archive | help
On 30 January 2015 at 01:13, Mark Johnston <markj@freebsd.org> wrote: > > It turns out that GNU ld implements a similar feature, albeit in a more > restrictive manner: a symbol named __start_<id> will have its value > filled in with the address of the section named <id>. The catch is that > <id> 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 :-) 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. 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPyFy2CzUKNrzX=s6p6nBDVs=oYbztJya=bU54WhBi34k4XvgQ>