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 via email to