public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [Bug tools/29719] New: eu-readelf -s=section is confusing
@ 2022-10-24 12:13 mliska at suse dot cz
  2022-10-24 12:29 ` [Bug tools/29719] " mliska at suse dot cz
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: mliska at suse dot cz @ 2022-10-24 12:13 UTC (permalink / raw)
  To: elfutils-devel

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-28  9:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24 12:13 [Bug tools/29719] New: eu-readelf -s=section is confusing mliska at suse dot cz
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

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).