https://sourceware.org/bugzilla/show_bug.cgi?id=28873
--- Comment #8 from Mark Wielaard <mark at klomp dot org> --- (In reply to Aaron Merey from comment #7) > This raises an interesting question: how do you calculate the number of > symbols in .dynsym without using section headers? > > 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. > > 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. -- You are receiving this mail because: You are on the CC list for the bug.