forked from Imagelibrary/binutils-gdb
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:
12
ld/ChangeLog
12
ld/ChangeLog
@@ -1,3 +1,15 @@
|
||||
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
|
||||
|
||||
5
ld/NEWS
5
ld/NEWS
@@ -1,7 +1,12 @@
|
||||
-*- 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.
|
||||
|
||||
5
ld/ld.h
5
ld/ld.h
@@ -252,9 +252,12 @@ typedef struct
|
||||
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;
|
||||
|
||||
@@ -1876,6 +1876,15 @@ in filename invoked by -R or --just-symbols
|
||||
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.
|
||||
|
||||
@@ -88,6 +88,7 @@ enum option_values
|
||||
OPTION_WARN_CONSTRUCTORS,
|
||||
OPTION_WARN_FATAL,
|
||||
OPTION_NO_WARN_FATAL,
|
||||
OPTION_NO_WARNINGS,
|
||||
OPTION_WARN_MULTIPLE_GP,
|
||||
OPTION_WARN_ONCE,
|
||||
OPTION_WARN_SECTION_ALIGN,
|
||||
|
||||
@@ -95,6 +95,9 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning)
|
||||
} 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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user