aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-10-26 04:36:59 -0700
committerH.J. Lu <hjl.tools@gmail.com>2024-02-16 05:03:06 -0800
commitd9511b64b85296f39ded68f82f7f25ee7d6b25fb (patch)
tree64a49c7fbb30937a736c7a13125cf504d4922f04 /ld
parent900c0f0aa3d78cd9e67ccd26fbc86224cef4c5b1 (diff)
downloadgdb-d9511b64b85296f39ded68f82f7f25ee7d6b25fb.zip
gdb-d9511b64b85296f39ded68f82f7f25ee7d6b25fb.tar.gz
gdb-d9511b64b85296f39ded68f82f7f25ee7d6b25fb.tar.bz2
ld: Add -plugin-save-temps
Add -plugin-save-temps to store plugin intermediate files permanently. It can be used to exam the final input object files generated from IR inputs. * NEWS: Mention -plugin-save-temps. * ld.h (ld_config_type): Add plugin_save_temps. * ld.texi: Document -plugin-save-temps. * ldlex.h (option_values): Add OPTION_PLUGIN_SAVE_TEMPS. * lexsup.c (ld_options): Add -plugin-save-temps. (parse_args): Handle OPTION_PLUGIN_SAVE_TEMPS. * plugin.c (plugin_call_cleanup): Don't call plugin cleanup_handler for -plugin-save-temps.
Diffstat (limited to 'ld')
-rw-r--r--ld/NEWS2
-rw-r--r--ld/ld.h3
-rw-r--r--ld/ld.texi4
-rw-r--r--ld/ldlex.h1
-rw-r--r--ld/lexsup.c6
-rw-r--r--ld/plugin.c19
6 files changed, 27 insertions, 8 deletions
diff --git a/ld/NEWS b/ld/NEWS
index a5a5b9f..f70d215 100644
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,5 +1,7 @@
-*- text -*-
+* Add -plugin-save-temps to store plugin intermediate files permanently.
+
Changes in 2.42:
* Add -z mark-plt/-z nomark-plt options to x86-64 ELF linker to mark PLT
diff --git a/ld/ld.h b/ld/ld.h
index 54d9079..fcdd9a2 100644
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -300,6 +300,9 @@ typedef struct
/* The size of the hash table to use. */
unsigned long hash_table_size;
+ /* If set, store plugin intermediate files permanently. */
+ bool plugin_save_temps;
+
/* If set, print discarded sections in map file output. */
bool print_map_discarded;
diff --git a/ld/ld.texi b/ld/ld.texi
index 4fda259..3cba778 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -1140,6 +1140,10 @@ Omit debugger symbol information (but not all symbols) from the output file.
Omit (or do not omit) global symbols defined in discarded sections.
Enabled by default.
+@kindex -plugin-save-temps
+@item -plugin-save-temps
+Store the plugin ``temporary'' intermediate files permanently.
+
@kindex -t
@kindex --trace
@cindex input files, displaying
diff --git a/ld/ldlex.h b/ld/ldlex.h
index e5ac2fa..d575562 100644
--- a/ld/ldlex.h
+++ b/ld/ldlex.h
@@ -146,6 +146,7 @@ enum option_values
#if BFD_SUPPORTS_PLUGINS
OPTION_PLUGIN,
OPTION_PLUGIN_OPT,
+ OPTION_PLUGIN_SAVE_TEMPS,
#endif /* BFD_SUPPORTS_PLUGINS */
OPTION_DEFAULT_SCRIPT,
OPTION_PRINT_OUTPUT_FORMAT,
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 099dff8..dad3b60 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -187,6 +187,9 @@ static const struct ld_option ld_options[] =
'\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH },
{ {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT},
'\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH },
+ { {"plugin-save-temps", no_argument, NULL, OPTION_PLUGIN_SAVE_TEMPS},
+ '\0', NULL, N_("Store plugin intermediate files permanently"),
+ ONE_DASH },
{ {"flto", optional_argument, NULL, OPTION_IGNORE},
'\0', NULL, N_("Ignored for GCC LTO option compatibility"),
ONE_DASH },
@@ -1211,6 +1214,9 @@ parse_args (unsigned argc, char **argv)
if (plugin_opt_plugin_arg (optarg))
einfo (_("%F%P: bad -plugin-opt option\n"));
break;
+ case OPTION_PLUGIN_SAVE_TEMPS:
+ config.plugin_save_temps = true;
+ break;
#endif /* BFD_SUPPORTS_PLUGINS */
case 'q':
link_info.emitrelocations = true;
diff --git a/ld/plugin.c b/ld/plugin.c
index f81ab02..13d29d6 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -1367,14 +1367,17 @@ plugin_call_cleanup (void)
{
if (curplug->cleanup_handler && !curplug->cleanup_done)
{
- enum ld_plugin_status rv;
- curplug->cleanup_done = true;
- called_plugin = curplug;
- rv = (*curplug->cleanup_handler) ();
- called_plugin = NULL;
- if (rv != LDPS_OK)
- info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"),
- curplug->name, rv);
+ if (!config.plugin_save_temps)
+ {
+ enum ld_plugin_status rv;
+ curplug->cleanup_done = true;
+ called_plugin = curplug;
+ rv = (*curplug->cleanup_handler) ();
+ called_plugin = NULL;
+ if (rv != LDPS_OK)
+ info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"),
+ curplug->name, rv);
+ }
dlclose (curplug->dlhandle);
}
curplug = curplug->next;