aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ld/ChangeLog12
-rw-r--r--ld/NEWS5
-rw-r--r--ld/ld.h5
-rw-r--r--ld/ld.texi9
-rw-r--r--ld/ldlex.h1
-rw-r--r--ld/ldmisc.c3
-rw-r--r--ld/lexsup.c8
7 files changed, 42 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 15cf800..9ba8cbc 100644
--- a/ld/ChangeLog
+++ b/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
diff --git a/ld/NEWS b/ld/NEWS
index d7ceb0c..24df91a 100644
--- a/ld/NEWS
+++ b/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.
diff --git a/ld/ld.h b/ld/ld.h
index f3086bf..2ac9f46 100644
--- a/ld/ld.h
+++ b/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;
diff --git a/ld/ld.texi b/ld/ld.texi
index 9daed2e..82527e3 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -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.
diff --git a/ld/ldlex.h b/ld/ldlex.h
index 8945825..31b7760 100644
--- a/ld/ldlex.h
+++ b/ld/ldlex.h
@@ -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,
diff --git a/ld/ldmisc.c b/ld/ldmisc.c
index 3a02f75..033e9c2 100644
--- a/ld/ldmisc.c
+++ b/ld/ldmisc.c
@@ -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;
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 0068ff5..d107bd7 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -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;