Add new linker option: --warn-orphan which generates warning messages when orphan sections are detected.

ld	* ld.h (struct ld_config_type): Add new field: warn_orphan.
	* ldlex.h (enum option_values): Add OPTION_WARN_ORPHAN and
	OPTION_NO_WARN_ORPHAN.
	* lexsup.c (ld_options): Add --warn-orphan and --no-warn-orphan.
	(parse_args): Handle the new options.
	* ldemul.c (ldemul_place_orphan): If requested, generate a warning
	message when an orphan section is placed in the output file.
	* ld.texinfo: Document the new option.
	* NEWS: Mention the new feature.

tests	* ld-elf/orphan-5.l: New test - checks the linker's output with
	--warn-orphan enabled.
	* ld-elf/elf.exp: Run the new test.
This commit is contained in:
Nick Clifton
2015-04-07 16:29:41 +01:00
parent 8a06aea71e
commit 3ea6077552
10 changed files with 67 additions and 0 deletions

View File

@@ -489,6 +489,10 @@ static const struct ld_option ld_options[] =
'\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES },
{ {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
'\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES },
{ {"warn-orphan", no_argument, NULL, OPTION_WARN_ORPHAN},
'\0', NULL, N_("Warn if any orphan sections are encountered"), TWO_DASHES },
{ {"no-warn-orphan", no_argument, NULL, OPTION_NO_WARN_ORPHAN},
'\0', NULL, N_("Do not warn if orphan sections are encountered (default)"), TWO_DASHES },
{ {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN},
'\0', NULL, N_("Warn if start of section changes due to alignment"),
TWO_DASHES },
@@ -1350,6 +1354,12 @@ parse_args (unsigned argc, char **argv)
case OPTION_WARN_ONCE:
config.warn_once = TRUE;
break;
case OPTION_WARN_ORPHAN:
config.warn_orphan = TRUE;
break;
case OPTION_NO_WARN_ORPHAN:
config.warn_orphan = FALSE;
break;
case OPTION_WARN_SECTION_ALIGN:
config.warn_section_align = TRUE;
break;