aboutsummaryrefslogtreecommitdiff
path: root/lto-plugin
diff options
context:
space:
mode:
authorRafael Avila de Espindola <espindola@google.com>2009-10-15 14:36:40 +0000
committerRafael Espindola <espindola@gcc.gnu.org>2009-10-15 14:36:40 +0000
commitb10071c5cf133fdfbcf75a0a5d4a495ce718c269 (patch)
treec58dd172d671e9b033f89a6f198b951bb014ba13 /lto-plugin
parentdda441650817aec18d07a390fec35ce24a516ee4 (diff)
downloadgcc-b10071c5cf133fdfbcf75a0a5d4a495ce718c269.zip
gcc-b10071c5cf133fdfbcf75a0a5d4a495ce718c269.tar.gz
gcc-b10071c5cf133fdfbcf75a0a5d4a495ce718c269.tar.bz2
lto-plugin.c (resolution_file): New.
2009-10-15 Rafael Avila de Espindola <espindola@google.com> * lto-plugin.c (resolution_file): New. (free_1): Update comment. (free_2): Free resolution_file. (write_resolution): Write resolution to specified file. Use the syms array from the symbol table. (all_symbols_read_handler): Delay call to free_1 past call to write_resolution. (process_option): Add a -resolution option. From-SVN: r152846
Diffstat (limited to 'lto-plugin')
-rw-r--r--lto-plugin/ChangeLog11
-rw-r--r--lto-plugin/lto-plugin.c30
2 files changed, 31 insertions, 10 deletions
diff --git a/lto-plugin/ChangeLog b/lto-plugin/ChangeLog
index a68e3ff..c8616fa 100644
--- a/lto-plugin/ChangeLog
+++ b/lto-plugin/ChangeLog
@@ -1,3 +1,14 @@
+2009-10-15 Rafael Avila de Espindola <espindola@google.com>
+
+ * lto-plugin.c (resolution_file): New.
+ (free_1): Update comment.
+ (free_2): Free resolution_file.
+ (write_resolution): Write resolution to specified file. Use the
+ syms array from the symbol table.
+ (all_symbols_read_handler): Delay call to free_1 past call to
+ write_resolution.
+ (process_option): Add a -resolution option.
+
2009-10-13 Richard Guenther <rguenther@suse.de>
* Makefile.am (liblto_plugin_la_LIBADD): Link against the
diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index 71b4961..ae484a9 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -97,6 +97,7 @@ static unsigned int num_pass_through_items;
static bool debug;
static bool nop;
+static char *resolution_file = NULL;
/* Parse an entry of the IL symbol table. The data to be parsed is pointed
by P and the result is written in ENTRY. The slot number is stored in SLOT.
@@ -228,7 +229,8 @@ translate (Elf_Data *symtab, struct plugin_symtab *out)
out->slots = slots;
}
-/* Free all memory that is no longer needed at the beginning of all_symbols_read. */
+/* Free all memory that is no longer needed after writing the symbol
+ resolution. */
static void
free_1 (void)
@@ -275,6 +277,12 @@ free_2 (void)
free (temp_obj_dir_name);
temp_obj_dir_name = NULL;
+
+ if (resolution_file)
+ {
+ free (resolution_file);
+ resolution_file = NULL;
+ }
}
/* Writes the relocations to disk. */
@@ -284,12 +292,12 @@ write_resolution (void)
{
unsigned int i;
FILE *f;
- /* FIXME: Disabled for now since we are not using the resolution file. */
- return;
+ if (!resolution_file)
+ return;
- /* FIXME: This should be a temporary file. */
- f = fopen ("resolution", "w");
+ f = fopen (resolution_file, "w");
+ assert (f);
fprintf (f, "%d\n", num_claimed_files);
@@ -297,8 +305,7 @@ write_resolution (void)
{
struct plugin_file_info *info = &claimed_files[i];
struct plugin_symtab *symtab = &info->symtab;
- struct ld_plugin_symbol *syms = calloc (symtab->nsyms,
- sizeof (struct ld_plugin_symbol));
+ struct ld_plugin_symbol *syms = symtab->syms;
unsigned j;
assert (syms);
@@ -312,7 +319,6 @@ write_resolution (void)
unsigned int resolution = syms[j].resolution;
fprintf (f, "%d %s\n", slot, lto_resolution_str[resolution]);
}
- free (syms);
}
fclose (f);
}
@@ -434,8 +440,6 @@ all_symbols_read_handler (void)
if (num_claimed_files == 0)
return LDPS_OK;
- free_1 ();
-
if (nop)
{
use_original_files ();
@@ -448,6 +452,8 @@ all_symbols_read_handler (void)
write_resolution ();
+ free_1 ();
+
for (i = 0; i < lto_wrapper_num_args; i++)
*lto_arg_ptr++ = lto_wrapper_argv[i];
@@ -608,6 +614,10 @@ process_option (const char *option)
debug = 1;
else if (strcmp (option, "-nop") == 0)
nop = 1;
+ else if (!strncmp (option, "-resolution=", strlen("-resolution=")))
+ {
+ resolution_file = strdup (option + strlen("-resolution="));
+ }
else if (!strncmp (option, "-pass-through=", strlen("-pass-through=")))
{
num_pass_through_items++;