Commit b10071c5 by Rafael Avila de Espindola Committed by Rafael Espindola

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
parent dda44165
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> 2009-10-13 Richard Guenther <rguenther@suse.de>
* Makefile.am (liblto_plugin_la_LIBADD): Link against the * Makefile.am (liblto_plugin_la_LIBADD): Link against the
......
...@@ -97,6 +97,7 @@ static unsigned int num_pass_through_items; ...@@ -97,6 +97,7 @@ static unsigned int num_pass_through_items;
static bool debug; static bool debug;
static bool nop; static bool nop;
static char *resolution_file = NULL;
/* Parse an entry of the IL symbol table. The data to be parsed is pointed /* 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. 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) ...@@ -228,7 +229,8 @@ translate (Elf_Data *symtab, struct plugin_symtab *out)
out->slots = slots; 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 static void
free_1 (void) free_1 (void)
...@@ -275,6 +277,12 @@ free_2 (void) ...@@ -275,6 +277,12 @@ free_2 (void)
free (temp_obj_dir_name); free (temp_obj_dir_name);
temp_obj_dir_name = NULL; temp_obj_dir_name = NULL;
if (resolution_file)
{
free (resolution_file);
resolution_file = NULL;
}
} }
/* Writes the relocations to disk. */ /* Writes the relocations to disk. */
...@@ -284,12 +292,12 @@ write_resolution (void) ...@@ -284,12 +292,12 @@ write_resolution (void)
{ {
unsigned int i; unsigned int i;
FILE *f; 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_file, "w");
f = fopen ("resolution", "w"); assert (f);
fprintf (f, "%d\n", num_claimed_files); fprintf (f, "%d\n", num_claimed_files);
...@@ -297,8 +305,7 @@ write_resolution (void) ...@@ -297,8 +305,7 @@ write_resolution (void)
{ {
struct plugin_file_info *info = &claimed_files[i]; struct plugin_file_info *info = &claimed_files[i];
struct plugin_symtab *symtab = &info->symtab; struct plugin_symtab *symtab = &info->symtab;
struct ld_plugin_symbol *syms = calloc (symtab->nsyms, struct ld_plugin_symbol *syms = symtab->syms;
sizeof (struct ld_plugin_symbol));
unsigned j; unsigned j;
assert (syms); assert (syms);
...@@ -312,7 +319,6 @@ write_resolution (void) ...@@ -312,7 +319,6 @@ write_resolution (void)
unsigned int resolution = syms[j].resolution; unsigned int resolution = syms[j].resolution;
fprintf (f, "%d %s\n", slot, lto_resolution_str[resolution]); fprintf (f, "%d %s\n", slot, lto_resolution_str[resolution]);
} }
free (syms);
} }
fclose (f); fclose (f);
} }
...@@ -434,8 +440,6 @@ all_symbols_read_handler (void) ...@@ -434,8 +440,6 @@ all_symbols_read_handler (void)
if (num_claimed_files == 0) if (num_claimed_files == 0)
return LDPS_OK; return LDPS_OK;
free_1 ();
if (nop) if (nop)
{ {
use_original_files (); use_original_files ();
...@@ -448,6 +452,8 @@ all_symbols_read_handler (void) ...@@ -448,6 +452,8 @@ all_symbols_read_handler (void)
write_resolution (); write_resolution ();
free_1 ();
for (i = 0; i < lto_wrapper_num_args; i++) for (i = 0; i < lto_wrapper_num_args; i++)
*lto_arg_ptr++ = lto_wrapper_argv[i]; *lto_arg_ptr++ = lto_wrapper_argv[i];
...@@ -608,6 +614,10 @@ process_option (const char *option) ...@@ -608,6 +614,10 @@ process_option (const char *option)
debug = 1; debug = 1;
else if (strcmp (option, "-nop") == 0) else if (strcmp (option, "-nop") == 0)
nop = 1; nop = 1;
else if (!strncmp (option, "-resolution=", strlen("-resolution=")))
{
resolution_file = strdup (option + strlen("-resolution="));
}
else if (!strncmp (option, "-pass-through=", strlen("-pass-through="))) else if (!strncmp (option, "-pass-through=", strlen("-pass-through=")))
{ {
num_pass_through_items++; num_pass_through_items++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment