public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "amerey at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: elfutils-devel@sourceware.org
Subject: [Bug tools/28873] Implement eu-readelf -D
Date: Fri, 03 Feb 2023 18:24:40 +0000	[thread overview]
Message-ID: <bug-28873-10460-7cslQG7jmu@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28873-10460@http.sourceware.org/bugzilla/>

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.

  parent reply	other threads:[~2023-02-03 18:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08 14:41 [Bug tools/28873] New: " dichen at redhat dot com
2022-02-08 14:43 ` [Bug tools/28873] " dichen at redhat dot com
2022-02-08 14:43 ` dichen at redhat dot com
2022-03-30 11:48 ` dichen at redhat dot com
2022-03-31 13:07 ` dichen at redhat dot com
2022-04-19  8:18 ` mark at klomp dot org
2022-08-08  9:33 ` dichen at redhat dot com
2022-08-08  9:38 ` dichen at redhat dot com
2022-08-08  9:42 ` dichen at redhat dot com
2023-01-16 13:30 ` dichen at redhat dot com
2023-01-16 13:39 ` dichen at redhat dot com
2023-02-03 18:24 ` amerey at redhat dot com [this message]
2023-02-04 17:02 ` mark at klomp dot org
2023-04-18 19:51 ` mark at klomp dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28873-10460-7cslQG7jmu@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).