Add a -w option to the linker to suppress warning and error messages.

PR 29654
	* ld.h (struct ld_config_type): Add no_warnings field.
	* ldlex.h (enum option_values): Add OPTION_NO_WARNINGS.
	* lexsup.c (ld_options): Add --no-warnings.
	(parse_args): Add support for -w and --no-warnings.
	* ldmisc.c (vfinfo): Return early if the message is a warning and
	-w has been enabled.
	* ld.texi (options): Document new command line option.
	* NEWS: Mention the new feature.
This commit is contained in:
Nick Clifton
2022-10-21 12:20:09 +01:00
parent 816be8d8b7
commit 4b2e7a577c
7 changed files with 42 additions and 1 deletions

View File

@@ -381,6 +381,9 @@ static const struct ld_option ld_options[] =
{ {"no-undefined", no_argument, NULL, OPTION_NO_UNDEFINED},
'\0', NULL, N_("Do not allow unresolved references in object files"),
TWO_DASHES },
{ {"no-warnings", no_argument, NULL, OPTION_NO_WARNINGS},
'w', NULL, N_("Do not display any warning or error messages"),
TWO_DASHES },
{ {"allow-shlib-undefined", no_argument, NULL, OPTION_ALLOW_SHLIB_UNDEFINED},
'\0', NULL, N_("Allow unresolved references in shared libraries"),
TWO_DASHES },
@@ -1554,6 +1557,11 @@ parse_args (unsigned argc, char **argv)
case OPTION_NO_WARN_FATAL:
config.fatal_warnings = false;
break;
case OPTION_NO_WARNINGS:
case 'w':
config.no_warnings = true;
config.fatal_warnings = false;
break;
case OPTION_WARN_MULTIPLE_GP:
config.warn_multiple_gp = true;
break;