@@ -85,7 +85,8 @@ static const struct argp_option options[] =
85
85
{ "relocs" , 'r' , NULL , 0 , N_ ("Display relocations" ), 0 },
86
86
{ "section-headers" , 'S' , NULL , 0 , N_ ("Display the sections' headers" ), 0 },
87
87
{ "sections" , 'S' , NULL , OPTION_ALIAS | OPTION_HIDDEN , NULL , 0 },
88
- { "symbols" , 's' , NULL , 0 , N_ ("Display the symbol table" ), 0 },
88
+ { "symbols" , 's' , "SECTION" , OPTION_ARG_OPTIONAL ,
89
+ N_ ("Display the symbol table sections" ), 0 },
89
90
{ "version-info" , 'V' , NULL , 0 , N_ ("Display versioning information" ), 0 },
90
91
{ "notes" , 'n' , NULL , 0 , N_ ("Display the ELF notes" ), 0 },
91
92
{ "arch-specific" , 'A' , NULL , 0 ,
@@ -157,6 +158,9 @@ static bool print_section_header;
157
158
/* True if the symbol table should be printed. */
158
159
static bool print_symbol_table ;
159
160
161
+ /* A specific section name, or NULL to print all symbol tables. */
162
+ static char * symbol_table_section ;
163
+
160
164
/* True if the version information should be printed. */
161
165
static bool print_version_info ;
162
166
@@ -389,6 +393,7 @@ parse_opt (int key, char *arg,
389
393
case 's' :
390
394
print_symbol_table = true;
391
395
any_control_option = true;
396
+ symbol_table_section = arg ;
392
397
break ;
393
398
case 'V' :
394
399
print_version_info = true;
@@ -2236,6 +2241,19 @@ print_symtab (Ebl *ebl, int type)
2236
2241
2237
2242
if (shdr != NULL && shdr -> sh_type == (GElf_Word ) type )
2238
2243
{
2244
+ if (symbol_table_section != NULL )
2245
+ {
2246
+ /* Get the section header string table index. */
2247
+ size_t shstrndx ;
2248
+ const char * sname ;
2249
+ if (unlikely (elf_getshdrstrndx (ebl -> elf , & shstrndx ) < 0 ))
2250
+ error (EXIT_FAILURE , 0 ,
2251
+ gettext ("cannot get section header string table index" ));
2252
+ sname = elf_strptr (ebl -> elf , shstrndx , shdr -> sh_name );
2253
+ if (sname == NULL || strcmp (sname , symbol_table_section ) != 0 )
2254
+ continue ;
2255
+ }
2256
+
2239
2257
if ((shdr -> sh_flags & SHF_COMPRESSED ) != 0 )
2240
2258
{
2241
2259
if (elf_compress (scn , 0 , 0 ) < 0 )
0 commit comments