PATCH: Add error handler to linker callback

H. J. Lu hjl@lucon.org
Wed Apr 23 21:04:00 GMT 2003


On Wed, Apr 23, 2003 at 11:34:25AM -0700, Ian Lance Taylor wrote:
> "H. J. Lu" <hjl@lucon.org> writes:
> 
> > BTW, does anyone have any objections to this patch:
> > 
> > http://sources.redhat.com/ml/binutils/2003-04/msg00342.html
> > 
> > I'd like to use it in bfd.
> 
> If you're going to change the formats accepted by vfinfo you need to
> change the comment above it describing it.
> 
> Note that vfinfo implements %v, so I'm not sure why you need %x and
> %lx.  If you don't really need %ld and %lu, I would vote against
> including them.  If we're going to reimplement printf, we should use a
> different approach.
> 
> I have no basic problem with adding the callback.
> 

How about this one?


H.J.
-------------- next part --------------
include/

2003-04-17  H.J. Lu <hjl@gnu.org>

	* bfdlink.h (bfd_link_callbacks): Add error_handler.

ld/

2003-04-17  H.J. Lu <hjl@gnu.org>

	* ldmain.c (link_callbacks): Initialize error_handler.

	* ldmisc.c (error_handler): New function.

	* ldmisc.h (error_handler): New prototype.

--- binutils/include/bfdlink.h.cb	2003-01-02 09:57:40.000000000 -0800
+++ binutils/include/bfdlink.h	2003-04-17 15:40:47.000000000 -0700
@@ -481,6 +481,11 @@ struct bfd_link_callbacks
   bfd_boolean (*notice)
     PARAMS ((struct bfd_link_info *, const char *name,
 	     bfd *abfd, asection *section, bfd_vma address));
+  /* A function which is called for reporting a linker error. ID is the
+     error identifier. The remaining input is the same as einfo () in
+     ld.  */
+  bfd_boolean (*error_handler)
+    PARAMS ((int id, const char * fmt, ...));
 };
 
 /* The linker builds link_order structures which tell the code how to
--- binutils/ld/ldmain.c.cb	2003-04-01 14:29:10.000000000 -0800
+++ binutils/ld/ldmain.c	2003-04-17 15:53:06.000000000 -0700
@@ -155,7 +155,8 @@ static struct bfd_link_callbacks link_ca
   reloc_overflow,
   reloc_dangerous,
   unattached_reloc,
-  notice
+  notice,
+  error_handler
 };
 
 struct bfd_link_info link_info;
--- binutils/ld/ldmisc.c.cb	2003-04-01 14:29:10.000000000 -0800
+++ binutils/ld/ldmisc.c	2003-04-17 21:23:39.000000000 -0700
@@ -506,3 +529,14 @@ ld_abort (file, line, fn)
   einfo (_("%P%F: please report this bug\n"));
   xexit (1);
 }
+
+bfd_boolean
+error_handler VPARAMS ((int id ATTRIBUTE_UNUSED, const char *fmt, ...))
+{
+  VA_OPEN (arg, fmt);
+  VA_FIXEDARG (arg, const char *, fmt);
+
+  vfinfo (stderr, fmt, arg);
+  VA_CLOSE (arg);
+  return TRUE;
+}
--- binutils/ld/ldmisc.h.cb	2001-09-27 10:28:34.000000000 -0700
+++ binutils/ld/ldmisc.h	2003-04-17 15:54:30.000000000 -0700
@@ -22,6 +22,7 @@
 #ifndef LDMISC_H
 #define LDMISC_H
 
+extern bfd_boolean error_handler PARAMS ((int, const char *, ...));
 extern void einfo PARAMS ((const char *, ...));
 extern void minfo PARAMS ((const char *, ...));
 extern void info_msg PARAMS ((const char *, ...));


More information about the Binutils mailing list