]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: No complaints for missing named sections implicit in -a.
authorRoland McGrath <roland@redhat.com>
Tue, 5 Jan 2010 04:25:09 +0000 (20:25 -0800)
committerRoland McGrath <roland@redhat.com>
Tue, 5 Jan 2010 04:25:09 +0000 (20:25 -0800)
src/ChangeLog
src/readelf.c

index c0e277a96b911f762bd27314b2d2687ed212d42d..a5cafc17d755bf13ff768a40d9e589f92e8dd159 100644 (file)
@@ -1,3 +1,10 @@
+2010-01-04  Roland McGrath  <roland@redhat.com>
+
+       * readelf.c (struct section_argument): Add bool member 'implicit'.
+       (parse_opt): Set it for -a cases, clear it for -x args.
+       (for_each_section_argument): Don't complain about a missing section by
+       name if it's implicit.
+
 2009-11-16  Roland McGrath  <roland@redhat.com>
 
        * readelf.c (print_string_section): Punt SHT_NOBITS like empty
index 345656793b7af9bfb2b9e679b2f7086a8a4f5741..1b8dc6eadd2726f593c830f0312fa91bbbb334cc 100644 (file)
@@ -1,5 +1,5 @@
 /* Print information from ELF file in human-readable form.
-   Copyright (C) 1999-2008, 2009 Red Hat, Inc.
+   Copyright (C) 1999-2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 1999.
 
@@ -202,6 +202,7 @@ struct section_argument
 {
   struct section_argument *next;
   const char *arg;
+  bool implicit;
 };
 
 /* Number of sections in the file.  */
@@ -282,11 +283,12 @@ static error_t
 parse_opt (int key, char *arg,
           struct argp_state *state __attribute__ ((unused)))
 {
-  void add_dump_section (const char *name)
+  void add_dump_section (const char *name, bool implicit)
   {
     struct section_argument *a = xmalloc (sizeof *a);
     a->arg = name;
     a->next = NULL;
+    a->implicit = implicit;
     struct section_argument ***tailp
       = key == 'x' ? &dump_data_sections_tail : &string_sections_tail;
     **tailp = a;
@@ -308,9 +310,9 @@ parse_opt (int key, char *arg,
       print_arch = true;
       print_notes = true;
       print_debug_sections |= section_exception;
-      add_dump_section (".strtab");
-      add_dump_section (".dynstr");
-      add_dump_section (".comment");
+      add_dump_section (".strtab", true);
+      add_dump_section (".dynstr", true);
+      add_dump_section (".comment", true);
       any_control_option = true;
       break;
     case 'A':
@@ -408,7 +410,7 @@ parse_opt (int key, char *arg,
        }
       /* Fall through.  */
     case 'x':
-      add_dump_section (arg);
+      add_dump_section (arg, false);
       any_control_option = true;
       break;
     case 'N':
@@ -7514,7 +7516,8 @@ for_each_section_argument (Elf *elf, const struct section_argument *list,
 
          if (unlikely (scn == NULL))
            {
-             error (0, 0, gettext ("\nsection '%s' does not exist"), a->arg);
+             if (!a->implicit)
+               error (0, 0, gettext ("\nsection '%s' does not exist"), a->arg);
              continue;
            }
        }