+2019-04-11 Faraz Shahbazker <fshahbazker@wavecomp.com>
+
+ * 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.
+
2019-04-11 H.J. Lu <hongjiu.lu@intel.com>
* ld.texi: Document -z cet-report=[none|warning|error].
-*- text -*-
+* Add command-line option --no-print-map-discarded.
+
Changes in 2.33:
* Add target handlers for AArch64 for ELF GNU program properties.
/* The common page size for ELF. */
bfd_vma commonpagesize;
+
+ /* If set, print discarded sections in map file output. */
+ bfd_boolean print_map_discarded;
} ld_config_type;
extern ld_config_type config;
is 0x1, and @file{bar.o}, whose 0xc0010001 property value is 0x1.
@end itemize
+@cindex link map discarded
+@kindex --print-map-discarded
+@kindex --no-print-map-discarded
+@item --print-map-discarded
+@itemx --no-print-map-discarded
+Print (or do not print) the list of discarded and garbage collected sections
+in the link map. Enabled by default.
+
@kindex -n
@cindex read-only text
@cindex NMAGIC
|| 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"));
OPTION_REQUIRE_DEFINED_SYMBOL,
OPTION_ORPHAN_HANDLING,
OPTION_FORCE_GROUP_ALLOCATION,
+ OPTION_PRINT_MAP_DISCARDED,
+ OPTION_NO_PRINT_MAP_DISCARDED,
};
/* The initial parser states. */
config.make_executable = TRUE;
config.magic_demand_paged = TRUE;
config.text_read_only = TRUE;
+ config.print_map_discarded = TRUE;
link_info.disable_target_specific_optimizations = -1;
command_line.warn_mismatch = TRUE;
{ {"orphan-handling", required_argument, NULL, OPTION_ORPHAN_HANDLING},
'\0', N_("=MODE"), N_("Control how orphan sections are handled."),
TWO_DASHES },
+ { {"print-map-discarded", no_argument, NULL, OPTION_PRINT_MAP_DISCARDED},
+ '\0', NULL, N_("Show discarded sections in map file output (default)"),
+ TWO_DASHES },
+ { {"no-print-map-discarded", no_argument, NULL, OPTION_NO_PRINT_MAP_DISCARDED},
+ '\0', NULL, N_("Do not show discarded sections in map file output"),
+ TWO_DASHES },
};
#define OPTION_COUNT ARRAY_SIZE (ld_options)
einfo (_("%F%P: invalid argument to option"
" \"--orphan-handling\"\n"));
break;
+
+ case OPTION_NO_PRINT_MAP_DISCARDED:
+ config.print_map_discarded = FALSE;
+ break;
+
+ case OPTION_PRINT_MAP_DISCARDED:
+ config.print_map_discarded = TRUE;
+ break;
}
}
]
run_dump_test "pr20306"
}
+
+run_dump_test "skip-map-discarded"
--- /dev/null
+#name: Check --no-print-map-discarded linker option
+#ld: -e 0 --gc-sections --no-print-map-discarded
+#map: skip-map-discarded.map
--- /dev/null
+#failif
+Discarded input sections
+#...
+ _foo.*
+#...
--- /dev/null
+.globl __start
+__start:
+ .section _foo
+foo:
+ .long 1