+2019-08-26 Mark Wielaard <mark@klomp.org>
+
+ * readelf (options): Add OPTION_ARG_OPTIONAL "SECTION" for notes.
+ (notes_section): New global variable.
+ (parse_opt): Set notes_section.
+ (handle_notes): Check if notes_section is set.
+
2019-07-26 Florian Weimer <fweimer@redhat.com>
Mark Wielaard <mark@klomp.org>
{ "symbols", 's', "SECTION", OPTION_ARG_OPTIONAL,
N_("Display the symbol table sections"), 0 },
{ "version-info", 'V', NULL, 0, N_("Display versioning information"), 0 },
- { "notes", 'n', NULL, 0, N_("Display the ELF notes"), 0 },
+ { "notes", 'n', "SECTION", OPTION_ARG_OPTIONAL, N_("Display the ELF notes"), 0 },
{ "arch-specific", 'A', NULL, 0,
N_("Display architecture specific information, if any"), 0 },
{ "exception", 'e', NULL, 0,
/* A specific section name, or NULL to print all symbol tables. */
static char *symbol_table_section;
+/* A specific section name, or NULL to print all ELF notes. */
+static char *notes_section;
+
/* True if the version information should be printed. */
static bool print_version_info;
case 'n':
print_notes = true;
any_control_option = true;
+ notes_section = arg;
break;
case 'r':
print_relocations = true;
/* Not what we are looking for. */
continue;
+ if (notes_section != NULL)
+ {
+ char *sname = elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
+ if (sname == NULL || strcmp (sname, notes_section) != 0)
+ continue;
+ }
+
printf (gettext ("\
\nNote section [%2zu] '%s' of %" PRIu64 " bytes at offset %#0" PRIx64 ":\n"),
elf_ndxscn (scn),