Add linker option to include local symbols in the linker map.

PR 16566
  * ldlang.c (ld_is_local_symbol): New function. (print_input_section): Add code to display local symbols in the section.
  * ldlex.h (enum option_values): Add OPTION_PRINT_MAP_LOCALS and OPTION_PRINT_MAP_LOCALS.
  * lexsup.c (ld_options[]): Add entries for --print-map-locals and --no-print-map-locals.
  * NEWS: Mention the new feature.
  * ld.h (struct ld_config_type): Add print_map_locals field.
  * ld.texi: Document the new command line option.
  * testsuite/ld-scripts/sizeof.s: Add a local symbol.
  * testsuite/ld-scripts/map-locals.d: New test control file.
  * testsuite/ld-scripts/map-address.exp: Run the new test.
This commit is contained in:
Nick Clifton
2023-05-10 10:29:52 +01:00
parent 2093c2af3c
commit 496917ce46
10 changed files with 168 additions and 2 deletions

View File

@@ -605,6 +605,12 @@ static const struct ld_option ld_options[] =
{ {"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 },
{ {"print-map-locals", no_argument, NULL, OPTION_PRINT_MAP_LOCALS},
'\0', NULL, N_("Show local symbols in map file output"),
TWO_DASHES },
{ {"no-print-map-locals", no_argument, NULL, OPTION_NO_PRINT_MAP_LOCALS},
'\0', NULL, N_("Do not show local symbols in map file output (default)"),
TWO_DASHES },
{ {"ctf-variables", no_argument, NULL, OPTION_CTF_VARIABLES},
'\0', NULL, N_("Emit names and types of static variables in CTF"),
TWO_DASHES },
@@ -1748,6 +1754,14 @@ parse_args (unsigned argc, char **argv)
config.print_map_discarded = true;
break;
case OPTION_NO_PRINT_MAP_LOCALS:
config.print_map_locals = false;
break;
case OPTION_PRINT_MAP_LOCALS:
config.print_map_locals = true;
break;
case OPTION_DEPENDENCY_FILE:
config.dependency_file = optarg;
break;