From: Roland McGrath Date: Tue, 5 Jan 2010 04:25:09 +0000 (-0800) Subject: readelf: No complaints for missing named sections implicit in -a. X-Git-Tag: elfutils-0.144~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e4061d064e300d2f94c2d528f4dff6e85290ba51;p=thirdparty%2Felfutils.git readelf: No complaints for missing named sections implicit in -a. --- diff --git a/src/ChangeLog b/src/ChangeLog index c0e277a96..a5cafc17d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-01-04 Roland McGrath + + * 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 * readelf.c (print_string_section): Punt SHT_NOBITS like empty diff --git a/src/readelf.c b/src/readelf.c index 345656793..1b8dc6ead 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -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 , 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; } }