public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "mliska at suse dot cz" <sourceware-bugzilla@sourceware.org>
To: elfutils-devel@sourceware.org
Subject: [Bug tools/29719] New: eu-readelf -s=section is confusing
Date: Mon, 24 Oct 2022 12:13:50 +0000	[thread overview]
Message-ID: <bug-29719-10460@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 29719
           Summary: eu-readelf -s=section is confusing
           Product: elfutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: tools
          Assignee: unassigned at sourceware dot org
          Reporter: mliska at suse dot cz
                CC: elfutils-devel at sourceware dot org, mjw at fedoraproject dot org
  Target Milestone: ---

Note there's a difference in between binutils and elfutils where the later on
has an optional argument:

       --symbols [section name]

I have a few comments:

1) it's confusing as one expects that all symbols in "section name" will be
printed, but it's not correct. It's the name of '.symtab' section.

2) readelf -sW xxx does not print anything, while binutils does:

The reason is simple, 'W' section is not found in the binary. I would recommend
printing a warning:

./src/readelf -sW /home/marxin/Programming/linux/arch/x86/kernel/head_64.o
WARNING: cannot find section: 'W'
WARNING: cannot find section: 'W'

diff --git a/src/readelf.c b/src/readelf.c
index a206e60e..465526c4 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -2431,6 +2431,7 @@ print_symtab (Ebl *ebl, int type)
   /* Find the symbol table(s).  For this we have to search through the
      section table.  */
   Elf_Scn *scn = NULL;
+  bool symtab_handled = false;

   while ((scn = elf_nextscn (ebl->elf, scn)) != NULL)
     {
@@ -2466,8 +2467,13 @@ print_symtab (Ebl *ebl, int type)
                            elf_ndxscn (scn), elf_errmsg (-1));
            }
          handle_symtab (ebl, scn, shdr);
+         symtab_handled = true;
        }
     }
+
+  if (!symtab_handled && symbol_table_section != NULL)
+    printf ("WARNING: %s: '%s'\n", _("cannot find section"),
+           symbol_table_section);
 }

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

             reply	other threads:[~2022-10-24 12:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24 12:13 mliska at suse dot cz [this message]
2022-10-24 12:29 ` [Bug tools/29719] " mliska at suse dot cz
2022-10-30  0:52 ` mark at klomp dot org
2022-11-15 16:12 ` mliska at suse dot cz
2022-11-25 13:31 ` mliska at suse dot cz
2022-11-28  9:59 ` mliska at suse dot cz

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-29719-10460@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).