aboutsummaryrefslogtreecommitdiff
path: root/lto-plugin/lto-plugin.c
diff options
context:
space:
mode:
authorRafael Avila de Espindola <espindola@google.com>2009-11-05 13:59:54 +0000
committerRafael Espindola <espindola@gcc.gnu.org>2009-11-05 13:59:54 +0000
commit94086ef69ccc24abf3f741461e6a7d3b3fa693cb (patch)
tree9e05e3ca317073115a78c159f1f6c78ab6c88cf7 /lto-plugin/lto-plugin.c
parent3be9759a0141b8d9915c70c771431f3fc11276cd (diff)
downloadgcc-94086ef69ccc24abf3f741461e6a7d3b3fa693cb.zip
gcc-94086ef69ccc24abf3f741461e6a7d3b3fa693cb.tar.gz
gcc-94086ef69ccc24abf3f741461e6a7d3b3fa693cb.tar.bz2
lto-plugin.c (temp_obj_dir_name): Remove.
2009-11-05 Rafael Avila de Espindola <espindola@google.com> * lto-plugin.c (temp_obj_dir_name): Remove. (arguments_file_name): New. (free_2): Free arguments_file_name instead of temp_obj_dir_name. (exec_lto_wrapper): Create arguments file with make_temp_file. (cleanup_handler): Don't remove the temporary directory. Remove the arguments file. (onload): Don't create the temporary directory. From-SVN: r153938
Diffstat (limited to 'lto-plugin/lto-plugin.c')
-rw-r--r--lto-plugin/lto-plugin.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index 3cf4e7c..e8e88cb 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -72,7 +72,7 @@ struct plugin_file_info
};
-static char *temp_obj_dir_name;
+static char *arguments_file_name;
static ld_plugin_register_claim_file register_claim_file;
static ld_plugin_add_symbols add_symbols;
static ld_plugin_register_all_symbols_read register_all_symbols_read;
@@ -291,8 +291,9 @@ free_2 (void)
claimed_files = NULL;
num_claimed_files = 0;
- free (temp_obj_dir_name);
- temp_obj_dir_name = NULL;
+ if (arguments_file_name)
+ free (arguments_file_name);
+ arguments_file_name = NULL;
if (resolution_file)
{
@@ -374,7 +375,6 @@ exec_lto_wrapper (char *argv[])
int t;
int status;
char *at_args;
- char *args_name;
FILE *args;
FILE *wrapper_output;
char *new_argv[3];
@@ -382,11 +382,11 @@ exec_lto_wrapper (char *argv[])
const char *errmsg;
/* Write argv to a file to avoid a command line that is too long. */
- t = asprintf (&at_args, "@%s/arguments", temp_obj_dir_name);
- check (t >= 0, LDPL_FATAL, "asprintf failed");
+ arguments_file_name = make_temp_file ("");
+ check (arguments_file_name, LDPL_FATAL,
+ "Failed to generate a temorary file name");
- args_name = at_args + 1;
- args = fopen (args_name, "w");
+ args = fopen (arguments_file_name, "w");
check (args, LDPL_FATAL, "could not open arguments file");
t = writeargv (&argv[1], args);
@@ -394,6 +394,9 @@ exec_lto_wrapper (char *argv[])
t = fclose (args);
check (t == 0, LDPL_FATAL, "could not close arguments file");
+ at_args = concat ("@", arguments_file_name, NULL);
+ check (at_args, LDPL_FATAL, "could not allocate");
+
new_argv[0] = argv[0];
new_argv[1] = at_args;
new_argv[2] = NULL;
@@ -426,8 +429,6 @@ exec_lto_wrapper (char *argv[])
pex_free (pex);
- t = unlink (args_name);
- check (t == 0, LDPL_FATAL, "could not unlink arguments file");
free (at_args);
}
@@ -511,25 +512,15 @@ static enum ld_plugin_status
cleanup_handler (void)
{
int t;
- char *arguments;
- struct stat buf;
if (debug)
return LDPS_OK;
- /* If we are being called from an error handler, it is possible
- that the arguments file is still exists. */
- t = asprintf (&arguments, "%s/arguments", temp_obj_dir_name);
- check (t >= 0, LDPL_FATAL, "asprintf failed");
- if (stat(arguments, &buf) == 0)
+ if (arguments_file_name)
{
- t = unlink (arguments);
+ t = unlink (arguments_file_name);
check (t == 0, LDPL_FATAL, "could not unlink arguments file");
}
- free (arguments);
-
- t = rmdir (temp_obj_dir_name);
- check (t == 0, LDPL_FATAL, "could not remove temporary directory");
free_2 ();
return LDPS_OK;
@@ -651,7 +642,6 @@ onload (struct ld_plugin_tv *tv)
{
struct ld_plugin_tv *p;
enum ld_plugin_status status;
- char *t;
unsigned version = elf_version (EV_CURRENT);
check (version != EV_NONE, LDPL_FATAL, "invalid ELF version");
@@ -715,8 +705,5 @@ onload (struct ld_plugin_tv *tv)
"could not register the all_symbols_read callback");
}
- temp_obj_dir_name = strdup ("tmp_objectsXXXXXX");
- t = mkdtemp (temp_obj_dir_name);
- assert (t == temp_obj_dir_name);
return LDPS_OK;
}