ld: Add --no-print-map-discarded option
Add a new option to disable the listing of discarded sections in map file output. The use case stems from a large application built with -ffunction-sections --gc-sections where the list of discarded sections blows up the map file output. The default behaviour remains to print discarded sections, but the new option allows us to disable it. ld/ * NEWS: Mention new option --no-print-map-discarded. * ld.h (ld_config_type) <print_map_discarded>: New field. * ldlang.c (lang_map): Conditionally output discarded sections in map files based on configuration option. * ldlex.h (option_values) <OPTION_PRINT_MAP_DISCARDED, OPTION_NO_PRINT_MAP_DISCARDED>: New. * ldmain.c (main): Enabled print_map_discarded by default. * lexsup.c (ld_options): Add new command-line options. (parse_args) <OPTION_NO_PRINT_MAP_DISCARDED, OPTION_PRINT_MAP_DISCARDED>: New cases. * ld.texi: Document new options. * testsuite/ld-gc/gc.exp: Add new test. * testsuite/ld-gc/skip-map-discarded.s: New file. * testsuite/ld-gc/skip-map-discarded.d: New file. * testsuite/ld-gc/skip-map-discarded.map: New file.
This commit is contained in:
parent
c30391f893
commit
035801cebe
12 changed files with 76 additions and 12 deletions
25
ld/ldlang.c
25
ld/ldlang.c
|
@ -2251,19 +2251,20 @@ lang_map (void)
|
|||
|| file->flags.just_syms)
|
||||
continue;
|
||||
|
||||
for (s = file->the_bfd->sections; s != NULL; s = s->next)
|
||||
if ((s->output_section == NULL
|
||||
|| s->output_section->owner != link_info.output_bfd)
|
||||
&& (s->flags & (SEC_LINKER_CREATED | SEC_KEEP)) == 0)
|
||||
{
|
||||
if (!dis_header_printed)
|
||||
{
|
||||
fprintf (config.map_file, _("\nDiscarded input sections\n\n"));
|
||||
dis_header_printed = TRUE;
|
||||
}
|
||||
if (config.print_map_discarded)
|
||||
for (s = file->the_bfd->sections; s != NULL; s = s->next)
|
||||
if ((s->output_section == NULL
|
||||
|| s->output_section->owner != link_info.output_bfd)
|
||||
&& (s->flags & (SEC_LINKER_CREATED | SEC_KEEP)) == 0)
|
||||
{
|
||||
if (! dis_header_printed)
|
||||
{
|
||||
fprintf (config.map_file, _("\nDiscarded input sections\n\n"));
|
||||
dis_header_printed = TRUE;
|
||||
}
|
||||
|
||||
print_input_section (s, TRUE);
|
||||
}
|
||||
print_input_section (s, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
minfo (_("\nMemory Configuration\n\n"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue