Better ld --fatal-warnings support
authorAlan Modra <amodra@gmail.com>
Fri, 30 Sep 2016 02:03:13 +0000 (11:33 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 30 Sep 2016 02:08:45 +0000 (11:38 +0930)
* ldmain.c (default_bfd_error_handler): New function pointer.
(ld_bfd_error_handler): New function.
(main): Arrange to call it on bfd errors/warnings.
(ld_bfd_assert_handler): Enable tail call.

ld/ChangeLog
ld/ldmain.c

index 3d08e3c4be7e3a711b020d0704c796c199ee4895..c4b43d50621f47e50025881444497bd12370dfac 100644 (file)
@@ -1,3 +1,10 @@
+2016-09-30  Alan Modra  <amodra@gmail.com>
+
+       * ldmain.c (default_bfd_error_handler): New function pointer.
+       (ld_bfd_error_handler): New function.
+       (main): Arrange to call it on bfd errors/warnings.
+       (ld_bfd_assert_handler): Enable tail call.
+
 2016-09-30  Alan Modra  <amodra@gmail.com>
 
        * ldlang.c (ignore_bfd_errors): Update params.
index e7a8dff9d262fe7d44bf3521c2815894593f44e8..29ef77f4f02f43e4c167c2e4794d1e60d81394d2 100644 (file)
@@ -158,6 +158,7 @@ static struct bfd_link_callbacks link_callbacks =
 };
 
 static bfd_assert_handler_type default_bfd_assert_handler;
+static bfd_error_handler_type default_bfd_error_handler;
 
 struct bfd_link_info link_info;
 \f
@@ -172,15 +173,24 @@ ld_cleanup (void)
     unlink_if_ordinary (output_filename);
 }
 
-/* If there's a BFD assertion, we'll notice and exit with an error
-   unless otherwise instructed.  */
+/* Hook to notice BFD assertions.  */
 
 static void
 ld_bfd_assert_handler (const char *fmt, const char *bfdver,
                       const char *file, int line)
 {
-  (*default_bfd_assert_handler) (fmt, bfdver, file, line);
   config.make_executable = FALSE;
+  (*default_bfd_assert_handler) (fmt, bfdver, file, line);
+}
+
+/* Hook the bfd error/warning handler for --fatal-warnings.  */
+
+static void
+ld_bfd_error_handler (const char *fmt, va_list ap)
+{
+  if (config.fatal_warnings)
+    config.make_executable = FALSE;
+  (*default_bfd_error_handler) (fmt, ap);
 }
 
 int
@@ -217,6 +227,9 @@ main (int argc, char **argv)
      leave no trace.  */
   default_bfd_assert_handler = bfd_set_assert_handler (ld_bfd_assert_handler);
 
+  /* Also hook the bfd error/warning handler for --fatal-warnings.  */
+  default_bfd_error_handler = bfd_set_error_handler (ld_bfd_error_handler);
+
   xatexit (ld_cleanup);
 
   /* Set up the sysroot directory.  */
This page took 0.042502 seconds and 4 git commands to generate.