https://sourceware.org/bugzilla/show_bug.cgi?id=28873
Aaron Merey <amerey at redhat dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amerey at redhat dot com --- Comment #7 from Aaron Merey <amerey at redhat dot com> --- (In reply to Di Chen from comment #5) > Because I use offset difference between SYMTAB and STRTAB to get the symbol > table entry number. > ``` > size_t syments = ((offs[i_strtab] - offs[i_symtab]) / > gelf_fsize(ebl->elf, ELF_T_SYM, 1, EV_CURRENT)); > ``` > > For a binary with SYMTAB STRTAB having different order, like upside down, or > having other section in between. eg. > [...] > It will mess up the syments (symbol table entry number) calculation. 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. 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. -- You are receiving this mail because: You are on the CC list for the bug.