+2022-10-21 Nick Clifton <nickc@redhat.com>
+
+ 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.
+
2022-08-30 Nick Clifton <nickc@redhat.com>
PR 29529
-*- text -*-
+* The linker has a new command line option to suppress the generation of any
+ warning or error messages. This can be useful when there is a need to create
+ a known non-working binary. The option is -w or --no-warnings.
+
* ld now supports zstd compressed debug sections. The new option
--compress-debug-sections=zstd compresses debug sections with zstd.
+
* Add --enable-default-compressed-debug-sections-algorithm={zlib,zstd}
that selects the default compression algorithm
for --enable-compressed-debug-sections.
changes due to the alignment of an input section. */
bool warn_section_align;
- /* If TRUE, warning messages are fatal */
+ /* If TRUE, warning messages are fatal. */
bool fatal_warnings;
+ /* If TRUE, warning and error messages are ignored. */
+ bool no_warnings;
+
sort_order sort_common;
bool text_read_only;
Treat all warnings as errors. The default behaviour can be restored
with the option @option{--no-fatal-warnings}.
+@kindex -w
+@kindex --no-warnings
+@item -w
+@itemx --no-warnings
+Do not display any warning or error messages. This overrides
+@option{--fatal-warnings} if it has been enabled. This option can be
+used when it is known that the output binary will not work, but there
+is still a need to create it.
+
@kindex --force-exe-suffix
@item --force-exe-suffix
Make sure that an output file has a .exe suffix.
OPTION_WARN_CONSTRUCTORS,
OPTION_WARN_FATAL,
OPTION_NO_WARN_FATAL,
+ OPTION_NO_WARNINGS,
OPTION_WARN_MULTIPLE_GP,
OPTION_WARN_ONCE,
OPTION_WARN_SECTION_ALIGN,
} type;
} args[9];
+ if (is_warning && config.no_warnings)
+ return;
+
for (arg_no = 0; arg_no < sizeof (args) / sizeof (args[0]); arg_no++)
args[arg_no].type = Bad;
{ {"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 },
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;