From 498cd2a0fdc89ee9a81ce4ad0019d64a1f6dbcd7 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 14 Feb 2011 09:53:15 +0000 Subject: [PATCH] * ldmain.c (remove_output): Rename to.. (ld_cleanup): ..this. Call bfd_cache_close_all and plugin_call_cleanup. (main): Adjust. * plugin.c (plugin_call_cleanup): Make global. (plugin_load_plugins): Don't register plugin_call_cleanup with xatexit. * plugin.h (plugin_call_cleanup): Declare. --- ld/ChangeLog | 9 +++++++++ ld/ldmain.c | 17 ++++++++--------- ld/plugin.c | 7 +------ ld/plugin.h | 5 ++++- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 147db32ef8b..a57210e89f4 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,12 @@ +2011-02-14 Alan Modra + + * ldmain.c (remove_output): Rename to.. + (ld_cleanup): ..this. Call bfd_cache_close_all and plugin_call_cleanup. + (main): Adjust. + * plugin.c (plugin_call_cleanup): Make global. + (plugin_load_plugins): Don't register plugin_call_cleanup with xatexit. + * plugin.h (plugin_call_cleanup): Declare. + 2011-02-13 Ralf Wildenhues * configure: Regenerate. diff --git a/ld/ldmain.c b/ld/ldmain.c index 19c42d98ac3..6e86c3d996f 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -174,15 +174,14 @@ static struct bfd_link_callbacks link_callbacks = struct bfd_link_info link_info; static void -remove_output (void) +ld_cleanup (void) { - if (output_filename) - { - if (link_info.output_bfd) - bfd_cache_close (link_info.output_bfd); - if (delete_output_file_on_failure) - unlink_if_ordinary (output_filename); - } + bfd_cache_close_all (); +#ifdef ENABLE_PLUGINS + plugin_call_cleanup (); +#endif + if (output_filename && delete_output_file_on_failure) + unlink_if_ordinary (output_filename); } int @@ -211,7 +210,7 @@ main (int argc, char **argv) bfd_set_error_program_name (program_name); - xatexit (remove_output); + xatexit (ld_cleanup); /* Set up the sysroot directory. */ ld_sysroot = get_sysroot (argc, argv); diff --git a/ld/plugin.c b/ld/plugin.c index b285787694b..86d80ca4a15 100644 --- a/ld/plugin.c +++ b/ld/plugin.c @@ -108,9 +108,6 @@ static bfd_boolean no_more_claiming = FALSE; TRUE is returned from the hook. */ static bfd_boolean plugin_cached_allow_multiple_defs = FALSE; -/* Call 'cleanup' hook for all plugins at exit. */ -static void plugin_call_cleanup (void); - /* List of tags to set in the constant leading part of the tv array. */ static const enum ld_plugin_tag tv_header_tags[] = { @@ -721,8 +718,6 @@ plugin_load_plugins (void) if (!curplug) return 0; - xatexit (plugin_call_cleanup); - /* First pass over plugins to find max # args needed so that we can size and allocate the tv array. */ while (curplug) @@ -820,7 +815,7 @@ plugin_call_all_symbols_read (void) } /* Call 'cleanup' hook for all plugins at exit. */ -static void +void plugin_call_cleanup (void) { plugin_t *curplug = plugins_list; diff --git a/ld/plugin.h b/ld/plugin.h index fc5f37f2dab..5b340be29ef 100644 --- a/ld/plugin.h +++ b/ld/plugin.h @@ -1,5 +1,5 @@ /* Plugin control for the GNU linker. - Copyright 2010 Free Software Foundation, Inc. + Copyright 2010, 2011 Free Software Foundation, Inc. This file is part of the GNU Binutils. @@ -50,6 +50,9 @@ extern int plugin_call_claim_file (const struct ld_plugin_input_file *file, /* Call 'all symbols read' hook for all plugins. */ extern int plugin_call_all_symbols_read (void); +/* Call 'cleanup' hook for all plugins at exit. */ +extern void plugin_call_cleanup (void); + /* Generate a dummy BFD to represent an IR file, for any callers of plugin_call_claim_file to use as the handle in the ld_plugin_input_file struct that they build to pass in. The BFD is initially writable, so -- 2.30.2