From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7783 Path: news.gmane.org!not-for-mail From: Alex Dowad Newsgroups: gmane.linux.lib.musl.general Subject: Question re: dynamic linking in musl Date: Wed, 27 May 2015 12:08:44 +0200 Message-ID: <20150527100844.GA306@alex-ThinkPad-L530> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1432721359 19250 80.91.229.3 (27 May 2015 10:09:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 May 2015 10:09:19 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7795-gllmg-musl=m.gmane.org@lists.openwall.com Wed May 27 12:09:19 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YxYH0-0006SK-Ib for gllmg-musl@m.gmane.org; Wed, 27 May 2015 12:09:18 +0200 Original-Received: (qmail 12217 invoked by uid 550); 27 May 2015 10:09:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 12164 invoked from network); 27 May 2015 10:09:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=cCsI0XP2+UB+Yz8ZLmlmMLXQdiO05sRZEdPy7U38ubM=; b=inXnWWb3SoPWl3aT6G8qAKhmhUMb/u8L+e0NDCwzo1UwwLaUrw3PYDaIWY/JQYGi0p BMVx5uJTu14ymHgNRUVkrxW9VVb2QDDLg2mStK6R8S/BEMqZxirEFHHLoIi9t5ZqiJfp d/DacjhDndhrOusLHmFSB3QJCKvqzCB1fD99Iup6f6vjg7sWjwxZOmK9AaqS0KP7VChW PVwAGyM+UfM/RVG8+Gg+v9NIIUQXDpFoGEOhW3Q1IDruLO/5Rmc31SmdZORvaOqk2T6g AhLyhs83zX3QvRGbAHQJETikvP7hUn4lcr8g0hggrEE1duj4w4/yf+xKP6OzCgnrxQrM Cs1Q== X-Received: by 10.180.231.4 with SMTP id tc4mr4462296wic.27.1432721333506; Wed, 27 May 2015 03:08:53 -0700 (PDT) Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:7783 Archived-At: Hi, I'm just dealing with a problem whereby rrdtool is spending >90% of its runtime in musl's dynamic linker (this is on Alpine Linux). This is making it too slow to do what we need it to do. After perusing some hotspots in dynlink.c (as measured by callgrind), there is something which looks like a big opportunity for optimization. I hope I'm not wrong. I probably am. I don't understand the code very well. do_relocs is called 3 times for each binary which needs relocation (including the main program and all its dependencies). Once for all the relocations in .rel.dyn, one for those in .rel.plt, and one for... something else. Haven't looked it up, not important right now. do_relocs iterates through all those relocations, and calls find_sym for each one to look up where the desired function, or variable, etc. can be found. find_sym iterates through *each* binary which has been loaded, including *all* the recursive dependencies, and does a hash lookup in each one to see if the desired symbol can be found. (Well, that's not quite right; for certain types of relocations, it skips the head of the list of binaries.) NOW: Is there any reason why dso->deps could not be used to search for symbols *only* in the dependencies of the binary which is currently being relocated? For example, rrdtool has dependencies on librrd, libxml, pango, libpng, libintl, libgobject, libharfbuzz, libfontconfig, libfreetype, libX11, libexpat, etc. etc. etc. When unresolved symbols in libX11 are being looked up, musl will start looking in librrd, right at the top of the list. But there's no way it will find any of libX11's relocations in librrd. The dependencies of libX11 are right down close to the *bottom* of the list. To add insult to injury, that wasteful lookup process will be repeated for each and every of the more than 1000 relocations in libX11. Hoping someone smarter than me can explain things... Thanks, AD