Fixes PR 17994 - which reported that dlltool was not deleting temporary files if it encounters a fatal error.
PR binutils/17994 * dlltool.c (temp_file_to_remove): New local array. (unlink_temp_files): New functions - unlinks any file in the temp_file_to_remove array, unless dotdeltemps is set. (gen_exp_file): Add temp files to array. (make_head): Likewise. (make_delay_head): Likewise. (make_tail): Likewise. (gen_lib_file): Call unlink_temp_files.
This commit is contained in:
parent
ca3fe95e46
commit
81fb971a3d
@ -1,3 +1,15 @@
|
|||||||
|
2015-03-05 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
PR binutils/17994
|
||||||
|
* dlltool.c (temp_file_to_remove): New local array.
|
||||||
|
(unlink_temp_files): New functions - unlinks any file in the
|
||||||
|
temp_file_to_remove array, unless dotdeltemps is set.
|
||||||
|
(gen_exp_file): Add temp files to array.
|
||||||
|
(make_head): Likewise.
|
||||||
|
(make_delay_head): Likewise.
|
||||||
|
(make_tail): Likewise.
|
||||||
|
(gen_lib_file): Call unlink_temp_files.
|
||||||
|
|
||||||
2015-02-28 Andrew Burgess <andrew.burgess@embecosm.com>
|
2015-02-28 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
* objcopy.c (update_sections): New list.
|
* objcopy.c (update_sections): New list.
|
||||||
|
@ -1994,6 +1994,31 @@ assemble_file (const char * source, const char * dest)
|
|||||||
run (as_name, cmd);
|
run (as_name, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char * temp_file_to_remove[5];
|
||||||
|
#define TEMP_EXPORT_FILE 0
|
||||||
|
#define TEMP_HEAD_FILE 1
|
||||||
|
#define TEMP_TAIL_FILE 2
|
||||||
|
#define TEMP_HEAD_O_FILE 3
|
||||||
|
#define TEMP_TAIL_O_FILE 4
|
||||||
|
|
||||||
|
static void
|
||||||
|
unlink_temp_files (void)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
if (dontdeltemps > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE (temp_file_to_remove); i++)
|
||||||
|
{
|
||||||
|
if (temp_file_to_remove[i])
|
||||||
|
{
|
||||||
|
unlink (temp_file_to_remove[i]);
|
||||||
|
temp_file_to_remove[i] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gen_exp_file (void)
|
gen_exp_file (void)
|
||||||
{
|
{
|
||||||
@ -2010,6 +2035,8 @@ gen_exp_file (void)
|
|||||||
/* xgettext:c-format */
|
/* xgettext:c-format */
|
||||||
fatal (_("Unable to open temporary assembler file: %s"), TMP_ASM);
|
fatal (_("Unable to open temporary assembler file: %s"), TMP_ASM);
|
||||||
|
|
||||||
|
temp_file_to_remove[TEMP_EXPORT_FILE] = TMP_ASM;
|
||||||
|
|
||||||
/* xgettext:c-format */
|
/* xgettext:c-format */
|
||||||
inform (_("Opened temporary file: %s"), TMP_ASM);
|
inform (_("Opened temporary file: %s"), TMP_ASM);
|
||||||
|
|
||||||
@ -2146,7 +2173,6 @@ gen_exp_file (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Add to the output file a way of getting to the exported names
|
/* Add to the output file a way of getting to the exported names
|
||||||
without using the import library. */
|
without using the import library. */
|
||||||
if (add_indirect)
|
if (add_indirect)
|
||||||
@ -2234,7 +2260,10 @@ gen_exp_file (void)
|
|||||||
assemble_file (TMP_ASM, exp_name);
|
assemble_file (TMP_ASM, exp_name);
|
||||||
|
|
||||||
if (dontdeltemps == 0)
|
if (dontdeltemps == 0)
|
||||||
unlink (TMP_ASM);
|
{
|
||||||
|
temp_file_to_remove[TEMP_EXPORT_FILE] = NULL;
|
||||||
|
unlink (TMP_ASM);
|
||||||
|
}
|
||||||
|
|
||||||
inform (_("Generated exports file"));
|
inform (_("Generated exports file"));
|
||||||
}
|
}
|
||||||
@ -2939,6 +2968,8 @@ make_head (void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp_file_to_remove[TEMP_HEAD_FILE] = TMP_HEAD_S;
|
||||||
|
|
||||||
fprintf (f, "%s IMAGE_IMPORT_DESCRIPTOR\n", ASM_C);
|
fprintf (f, "%s IMAGE_IMPORT_DESCRIPTOR\n", ASM_C);
|
||||||
fprintf (f, "\t.section\t.idata$2\n");
|
fprintf (f, "\t.section\t.idata$2\n");
|
||||||
|
|
||||||
@ -3000,6 +3031,7 @@ make_head (void)
|
|||||||
fatal (_("failed to open temporary head file: %s: %s"),
|
fatal (_("failed to open temporary head file: %s: %s"),
|
||||||
TMP_HEAD_O, bfd_get_errmsg ());
|
TMP_HEAD_O, bfd_get_errmsg ());
|
||||||
|
|
||||||
|
temp_file_to_remove[TEMP_HEAD_O_FILE] = TMP_HEAD_O;
|
||||||
return abfd;
|
return abfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3015,6 +3047,8 @@ make_delay_head (void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp_file_to_remove[TEMP_HEAD_FILE] = TMP_HEAD_S;
|
||||||
|
|
||||||
/* Output the __tailMerge__xxx function */
|
/* Output the __tailMerge__xxx function */
|
||||||
fprintf (f, "%s Import trampoline\n", ASM_C);
|
fprintf (f, "%s Import trampoline\n", ASM_C);
|
||||||
fprintf (f, "\t.section\t.text\n");
|
fprintf (f, "\t.section\t.text\n");
|
||||||
@ -3083,6 +3117,7 @@ make_delay_head (void)
|
|||||||
fatal (_("failed to open temporary head file: %s: %s"),
|
fatal (_("failed to open temporary head file: %s: %s"),
|
||||||
TMP_HEAD_O, bfd_get_errmsg ());
|
TMP_HEAD_O, bfd_get_errmsg ());
|
||||||
|
|
||||||
|
temp_file_to_remove[TEMP_HEAD_O_FILE] = TMP_HEAD_O;
|
||||||
return abfd;
|
return abfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3098,6 +3133,8 @@ make_tail (void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp_file_to_remove[TEMP_TAIL_FILE] = TMP_TAIL_S;
|
||||||
|
|
||||||
if (!no_idata4)
|
if (!no_idata4)
|
||||||
{
|
{
|
||||||
fprintf (f, "\t.section\t.idata$4\n");
|
fprintf (f, "\t.section\t.idata$4\n");
|
||||||
@ -3154,6 +3191,7 @@ make_tail (void)
|
|||||||
fatal (_("failed to open temporary tail file: %s: %s"),
|
fatal (_("failed to open temporary tail file: %s: %s"),
|
||||||
TMP_TAIL_O, bfd_get_errmsg ());
|
TMP_TAIL_O, bfd_get_errmsg ());
|
||||||
|
|
||||||
|
temp_file_to_remove[TEMP_TAIL_O_FILE] = TMP_TAIL_O;
|
||||||
return abfd;
|
return abfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3179,6 +3217,8 @@ gen_lib_file (int delay)
|
|||||||
/* xgettext:c-format */
|
/* xgettext:c-format */
|
||||||
inform (_("Creating library file: %s"), imp_name);
|
inform (_("Creating library file: %s"), imp_name);
|
||||||
|
|
||||||
|
xatexit (unlink_temp_files);
|
||||||
|
|
||||||
bfd_set_format (outarch, bfd_archive);
|
bfd_set_format (outarch, bfd_archive);
|
||||||
outarch->has_armap = 1;
|
outarch->has_armap = 1;
|
||||||
outarch->is_thin_archive = 0;
|
outarch->is_thin_archive = 0;
|
||||||
@ -3248,13 +3288,7 @@ gen_lib_file (int delay)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Delete all the temp files. */
|
/* Delete all the temp files. */
|
||||||
if (dontdeltemps == 0)
|
unlink_temp_files ();
|
||||||
{
|
|
||||||
unlink (TMP_HEAD_O);
|
|
||||||
unlink (TMP_HEAD_S);
|
|
||||||
unlink (TMP_TAIL_O);
|
|
||||||
unlink (TMP_TAIL_S);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dontdeltemps < 2)
|
if (dontdeltemps < 2)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user