From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 991073857B9B; Sat, 4 Feb 2023 17:02:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 991073857B9B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675530179; bh=1CWCOi8ke+Zz9p9ywPBdEEWcKkctC4svm8k2rwpVYnM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DzJVZG/YZlWkgvpqKuKtZ44shYuxuApx4YGjF4HYG3rt3jP86iveIHdzqaH3v5vk3 8Yuf2x/a68/SDkPM6KaeClwjRe9D116sU6DhinaVmwBqnOzfQO/HEWKH+cnzG0Gels Q3i+FGTLTRH0GA7y2by7Uy+bdjy5JcHnrDilQ4rE= From: "mark at klomp dot org" To: elfutils-devel@sourceware.org Subject: [Bug tools/28873] Implement eu-readelf -D Date: Sat, 04 Feb 2023 17:02:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: tools X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mark at klomp dot org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: dichen at redhat dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D28873 --- Comment #8 from Mark Wielaard --- (In reply to Aaron Merey from comment #7)=20 > This raises an interesting question: how do you calculate the number of > symbols in .dynsym without using section headers? >=20 > I figured there'd some kind of "DT_SYMTABNUM" value somewhere but > unfortunately the answer doesn't appear to be so straightforward. It has been proposed, but not (yet) adopted: https://groups.google.com/g/generic-abi/c/9L03yrxXPBc (sorry, a google groups link, there should be a normal archive, but I cannot find it right now). If that was adopted and linkers would generate it, then this question would indeed have a simple answer. Sadly, it isn't :{ > Judging from the binutils readelf source code you need to use information= in > the .hash and .gnu.hash sections to calculate the number of entries.=20 >=20 > To complicate things even more, a binary can contain either .hash or > .gnu.hash or both and computing the number of .dynsym entries is different > in each case. See binutils/readelf.c:get_num_dynamic_syms, you may need to > implement some of this in your patch. If there is a .hash section then it is fairly easy, the first word is the number of symbols the hash/symbol table describes. If it is a .gnu.hash section then sadly you have to parse and go through the whole hashtable and count. There is an implementation already in elfutils, but it is a bit hiden and obscure if you don't know what you are looking for. Search for "Figure out = the size of the symbol table" in libdwfl/dwfl_module_getdwarf.c. --=20 You are receiving this mail because: You are on the CC list for the bug.=