From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1620 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: ldso : dladdr support Date: Fri, 17 Aug 2012 01:39:34 -0400 Message-ID: <20120817053934.GS27715@brightrain.aerifal.cx> References: <5020DA13.6080803@gmail.com> <20120807114627.GG30810@port70.net> <50212306.6070402@gmail.com> <20120807230933.GC27715@brightrain.aerifal.cx> <502237A1.1000805@gmail.com> <20120808115202.GL30810@port70.net> <5022703B.3090105@gmail.com> <20120811230536.GQ27715@brightrain.aerifal.cx> 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 1345181908 12810 80.91.229.3 (17 Aug 2012 05:38:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 17 Aug 2012 05:38:28 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1621-gllmg-musl=m.gmane.org@lists.openwall.com Fri Aug 17 07:38:28 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1T2FGN-0001T9-2m for gllmg-musl@plane.gmane.org; Fri, 17 Aug 2012 07:38:27 +0200 Original-Received: (qmail 23783 invoked by uid 550); 17 Aug 2012 05:38:25 -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 23773 invoked from network); 17 Aug 2012 05:38:25 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:1620 On Thu, Aug 16, 2012 at 12:41:48AM +0200, boris brezillon wrote: > > Sorry for taking a while to get back to you. I haven't had as much > > time to work on musl the past couple weeks and some other topics (like > > mips dynamic linking) had priority, but I hope to have more again for > > a while now. Here's a quick review of some things that will hopefully > > turn into a discussion for improving/simplifying the code. > No problem. > Thanks for the review. > Do you want to discuss it on irc or keep going on the mailing list? List is best I think, but I don't mind having some specific discussions that need more real-time feedback on IRC. > > BTW, while I _want_ it to be safe, it's possible that early switches > > (early meaning prior to the comment in __dynlink that says libc is now > > fully functional) will actually fail to work/crash on some archs... So > > this needs consideration too. > > > I didn't knew that. Could explain me why? The compiler may compile a switch to something like: jmp *local_jmptable@GOTOFF(%ebx,%ecx,4) where the local_jmptable needs to contain absolute jump addresses. Prior to relocation, it will obly have the load-address-relative addresses. > > I'm not seeing why this function needs hash tables at all. It's not > > looking up symbols, just iterating over the entire symbol table, no? > > Please explain if I'm mistaken. > I don't see any other way to know the sym table size except reading > the .dynsym section header. Indeed, I missed the fact that there's no DT_* entry reporting the symbol table size. I checked how readelf reports the number of entries, and it's using the section headers. I'm under the impression that using them would not be valid for the dynamic linker; reportedly ELF files are supposed to be valid even with the section headers stripped. > That's why I'm iterating over the hash table. > For sysv hash the nchain (second entry of hash table) gives the sym table size. > For gnu hash It's a little bit more complicated (see > https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections). Wow, leave it to the GNU folks to take something simple and make it difficult... > Should we parse the .dynsym section header and store the sym table > size in dso struct? > Do you see any other way to get the dynsym table size or at least > iterate over the dynsym table (specific pattern for last element ?). I've been looking but I don't see any way yet. Rich