]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: For -x/-p, print all sections with matching name, not just one.
authorRoland McGrath <roland@redhat.com>
Wed, 11 Aug 2010 20:04:12 +0000 (13:04 -0700)
committerRoland McGrath <roland@redhat.com>
Wed, 11 Aug 2010 20:04:12 +0000 (13:04 -0700)
src/ChangeLog
src/readelf.c

index 5cba1cb5ad1aad7a962328ce42994e2b85ccd311..0c9858cdc10c9d37abbf32b15f547695e026e989 100644 (file)
@@ -1,3 +1,8 @@
+2010-08-11  Roland McGrath  <roland@redhat.com>
+
+       * readelf.c (for_each_section_argument): Process all sections with
+       matching name, not just the first.
+
 2010-07-26  Roland McGrath  <roland@redhat.com>
 
        * readelf.c (print_ops): Take new argument for CU version.
index 1564e37f59dddd463e5655211890f92779e84c35..48f0731781a4581a9d9f6a64405d2e4d59f4bf88 100644 (file)
@@ -7758,6 +7758,7 @@ for_each_section_argument (Elf *elf, const struct section_argument *list,
        {
          /* Need to look up the section by name.  */
          scn = NULL;
+         bool found = false;
          while ((scn = elf_nextscn (elf, scn)) != NULL)
            {
              if (gelf_getshdr (scn, &shdr_mem) == NULL)
@@ -7766,18 +7767,15 @@ for_each_section_argument (Elf *elf, const struct section_argument *list,
              if (name == NULL)
                continue;
              if (!strcmp (name, a->arg))
-               break;
+               {
+                 found = true;
+                 (*dump) (scn, &shdr_mem, name);
+               }
            }
 
-         if (unlikely (scn == NULL))
-           {
-             if (!a->implicit)
-               error (0, 0, gettext ("\nsection '%s' does not exist"), a->arg);
-             continue;
-           }
+         if (unlikely (!found) && !a->implicit)
+           error (0, 0, gettext ("\nsection '%s' does not exist"), a->arg);
        }
-
-      (*dump) (scn, &shdr_mem, name);
     }
 }