diff options
author | Roland McGrath <roland@redhat.com> | 2010-08-11 13:04:12 -0700 |
---|---|---|
committer | Roland McGrath <roland@redhat.com> | 2010-08-11 13:04:12 -0700 |
commit | f4763cf246af5d001ae0690c7c0f0acaca78fc0c (patch) | |
tree | 22d7b64f9fd84556b4da4871f8507b6df8e797c9 | |
parent | bb72de28371692812cbccb833af70e73ed11b768 (diff) | |
download | elfutils-f4763cf246af5d001ae0690c7c0f0acaca78fc0c.tar.gz |
readelf: For -x/-p, print all sections with matching name, not just one.
-rw-r--r-- | src/ChangeLog | 5 | ||||
-rw-r--r-- | src/readelf.c | 16 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5cba1cb5..0c9858cd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -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. diff --git a/src/readelf.c b/src/readelf.c index 1564e37f..48f07317 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -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); } } |