public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "dichen at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: elfutils-devel@sourceware.org
Subject: [Bug tools/28873] Implement eu-readelf -D
Date: Mon, 16 Jan 2023 13:30:16 +0000	[thread overview]
Message-ID: <bug-28873-10460-JBK09ay5Ck@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28873-10460@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=28873

--- Comment #5 from Di Chen <dichen at redhat dot com> ---
Created attachment 14600
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14600&action=edit
readelf: display dynamic symtab without section headers

```
# failed to print symtab of a binary which has section headers removed.
$ ./src/readelf -s ~/test/a.out

# it works with "-D" for a binary which has section headers removed.
$ ./src/readelf -Ds ~/test/a.out 
    0: 0000000000000000      0 NOTYPE  LOCAL  DEFAULT    UNDEF 
    1: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF
__libc_start_main@GLIBC_2.34 (2)
    2: 0000000000000000      0 NOTYPE  WEAK   DEFAULT    UNDEF __gmon_start__
```

It works well for binaries which has SYMTAB section right after STRTAB section.
```
$ readelf -Dd ~/test/a.out 

Dynamic section at offset 0x2e60 contains 20 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000c (INIT)               0x401000
 0x000000000000000d (FINI)               0x401124
 0x0000000000000019 (INIT_ARRAY)         0x403e50
 0x000000000000001b (INIT_ARRAYSZ)       8 (bytes)
 0x000000000000001a (FINI_ARRAY)         0x403e58
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x4003c0
 0x0000000000000005 (STRTAB)             0x400428
 0x0000000000000006 (SYMTAB)             0x4003e0
 0x000000000000000a (STRSZ)              55 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000007 (RELA)               0x400488
 0x0000000000000008 (RELASZ)             48 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffffe (VERNEED)            0x400468
 0x000000006fffffff (VERNEEDNUM)         1
 0x000000006ffffff0 (VERSYM)             0x400460
 0x0000000000000000 (NULL)               0x0
```
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));
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2023-01-16 13:30 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 [this message]
2023-01-16 13:39 ` dichen at redhat dot com
2023-02-03 18:24 ` amerey at redhat dot com
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-JBK09ay5Ck@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).