[prev in list] [next in list] [prev in thread] [next in thread] 

List:       binutils-cvs
Subject:    [binutils-gdb] Better ld --fatal-warnings support
From:       Alan Modra <amodra () sourceware ! org>
Date:       2016-09-30 8:14:28
Message-ID: 20160930081428.76691.qmail () sourceware ! org
[Download RAW message or body]

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4519d071387f374932616b588ddb4ec8cabe2a52

commit 4519d071387f374932616b588ddb4ec8cabe2a52
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Sep 30 11:33:13 2016 +0930

    Better ld --fatal-warnings support
    
    	* 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.

Diff:
---
 ld/ChangeLog |  7 +++++++
 ld/ldmain.c  | 19 ++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 3d08e3c..c4b43d5 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,12 @@
 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.
 
 2016-09-29  H.J. Lu  <hongjiu.lu@intel.com>
diff --git a/ld/ldmain.c b/ld/ldmain.c
index e7a8dff..29ef77f 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -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;
 
@@ -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.  */

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic