aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-11-23 08:39:23 -0800
committerH.J. Lu <hjl.tools@gmail.com>2012-11-23 08:42:09 -0800
commitf783c55f3ffba3ba69dbdecc5b7c3047cbd06dac (patch)
treecb9e8dacce5475a1159b10946bdd2444f3b96785
parentabfe07af5dab45464e5c882f152bdac62376a0d7 (diff)
downloadbinutils-hjl/lto/master+error.tar.gz
Improve plugin error handlinghjl/lto/master+error
This patch improves plugin error handling: 1. Use dlerror to report error whenerve possible. 2. Report plugin error code on error. 3. Only issue cleanup error during cleanup. Conflicts: ld/plugin.c
-rw-r--r--ld/ChangeLog.error16
-rw-r--r--ld/ldmain.c3
-rw-r--r--ld/plugin.c15
-rw-r--r--ld/plugin.h2
-rw-r--r--ld/testsuite/ChangeLog.error4
-rw-r--r--ld/testsuite/ld-plugin/plugin-2.d2
-rw-r--r--ld/testsuite/ld-plugin/plugin-4.d2
7 files changed, 30 insertions, 14 deletions
diff --git a/ld/ChangeLog.error b/ld/ChangeLog.error
new file mode 100644
index 000000000..dce90ef29
--- /dev/null
+++ b/ld/ChangeLog.error
@@ -0,0 +1,16 @@
+2012-11-22 H.J. Lu <hongjiu.lu@intel.com>
+
+ * ldmain.c (main): Don't check plugin_load_plugins return.
+
+ * lexsup.c (parse_args): Don't check plugin_opt_plugin return.
+
+ * plugin.c (dl_error): New.
+ (plugin_opt_plugin): Change return type to void. Stop on
+ dlopen error and report error with dl_error ().
+ (plugin_load_plugins): Change return type to void. Stop on
+ dlsym error and report error with dl_error (). Don't use
+ set_plugin_error.
+ (plugin_call_cleanup): Issue an error for each plugin.
+
+ * plugin.h (plugin_opt_plugin): Change return type to void.
+ (plugin_load_plugins): Likewise.
diff --git a/ld/ldmain.c b/ld/ldmain.c
index d73b72101..0bc8059f8 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -311,8 +311,7 @@ main (int argc, char **argv)
#ifdef ENABLE_PLUGINS
/* Now all the plugin arguments have been gathered, we can load them. */
- if (plugin_load_plugins ())
- einfo (_("%P%F: %s: error loading plugin\n"), plugin_error_plugin ());
+ plugin_load_plugins ();
#endif /* ENABLE_PLUGINS */
ldemul_set_symbols ();
diff --git a/ld/plugin.c b/ld/plugin.c
index 90af4aed9..8c910fae6 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -798,7 +798,7 @@ plugin_active_plugins_p (void)
}
/* Load up and initialise all plugins after argument parsing. */
-int
+void
plugin_load_plugins (void)
{
struct ld_plugin_tv *my_tv;
@@ -807,7 +807,7 @@ plugin_load_plugins (void)
/* If there are no plugins, we need do nothing this run. */
if (!curplug)
- return 0;
+ return;
/* First pass over plugins to find max # args needed so that we
can size and allocate the tv array. */
@@ -840,7 +840,8 @@ plugin_load_plugins (void)
rv = (*onloadfn) (my_tv);
called_plugin = NULL;
if (rv != LDPS_OK)
- return set_plugin_error (curplug->name);
+ einfo (_("%P%F: %s: error loading plugin: %d\n"),
+ curplug->name, rv);
curplug = curplug->next;
}
@@ -853,8 +854,6 @@ plugin_load_plugins (void)
plugin_callbacks.notice = &plugin_notice;
link_info.notice_all = TRUE;
link_info.callbacks = &plugin_callbacks;
-
- return 0;
}
/* Call 'claim file' hook for all plugins. */
@@ -962,15 +961,13 @@ plugin_call_cleanup (void)
rv = (*curplug->cleanup_handler) ();
called_plugin = NULL;
if (rv != LDPS_OK)
- set_plugin_error (curplug->name);
+ info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"),
+ curplug->name, rv);
}
dlclose (curplug->dlhandle);
}
curplug = curplug->next;
}
- if (plugin_error_p ())
- info_msg (_("%P: %s: error in plugin cleanup (ignored)\n"),
- plugin_error_plugin ());
}
/* To determine which symbols should be resolved LDPR_PREVAILING_DEF
diff --git a/ld/plugin.h b/ld/plugin.h
index b2d60db5f..d41aa5369 100644
--- a/ld/plugin.h
+++ b/ld/plugin.h
@@ -47,7 +47,7 @@ extern int plugin_opt_plugin_arg (const char *arg);
extern bfd_boolean plugin_active_plugins_p (void);
/* Load up and initialise all plugins after argument parsing. */
-extern int plugin_load_plugins (void);
+extern void plugin_load_plugins (void);
/* Return name of plugin which caused an error in any of the above. */
extern const char *plugin_error_plugin (void);
diff --git a/ld/testsuite/ChangeLog.error b/ld/testsuite/ChangeLog.error
new file mode 100644
index 000000000..67a0b096c
--- /dev/null
+++ b/ld/testsuite/ChangeLog.error
@@ -0,0 +1,4 @@
+2012-11-22 H.J. Lu <hongjiu.lu@intel.com>
+
+ * ld-plugin/plugin-2.d: Update expected error message.
+ * ld-plugin/plugin-4.d: Likewise.
diff --git a/ld/testsuite/ld-plugin/plugin-2.d b/ld/testsuite/ld-plugin/plugin-2.d
index 0ce111f10..983f1cf9d 100644
--- a/ld/testsuite/ld-plugin/plugin-2.d
+++ b/ld/testsuite/ld-plugin/plugin-2.d
@@ -18,5 +18,5 @@ Hello from testplugin.
.*: LDPT_OPTION 'failonload'
.*: LDPT_NULL value 0x0 \(0\)
#...
-.*ld.*:.*ldtestplug.*: error loading plugin
+.*ld.*:.*ldtestplug.*: error loading plugin: 3
#...
diff --git a/ld/testsuite/ld-plugin/plugin-4.d b/ld/testsuite/ld-plugin/plugin-4.d
index e17565e54..9f25fc682 100644
--- a/ld/testsuite/ld-plugin/plugin-4.d
+++ b/ld/testsuite/ld-plugin/plugin-4.d
@@ -20,5 +20,5 @@ Hello from testplugin.
.*: LDPT_NULL value 0x0 \(0\)
#...
hook called: cleanup.
-.*ld.*:.*ldtestplug.*: error in plugin cleanup \(ignored\)
+.*ld.*:.*ldtestplug.*: error in plugin cleanup: 3 \(ignored\)
#...