static void ld_cleanup (void) { bfd_cache_close_all (); if (output_filename && delete_output_file_on_failure) unlink_if_ordinary (output_filename); }
/* Unlink FILE unless we are debugging. */ void maybe_unlink (const char *file) { if (debug) notice ("[Leaving %s]\n", file); else unlink_if_ordinary (file); }
static void ld_cleanup (void) { bfd_cache_close_all (); #ifdef ENABLE_PLUGINS plugin_call_cleanup (); #endif if (output_filename && delete_output_file_on_failure) unlink_if_ordinary (output_filename); }
static void remove_output (void) { if (output_filename) { if (link_info.output_bfd) bfd_cache_close (link_info.output_bfd); if (delete_output_file_on_failure) unlink_if_ordinary (output_filename); } }
void as_fatal (const char *format, ...) { va_list args; as_show_where (); va_start (args, format); fprintf (stderr, _("Fatal error: ")); vfprintf (stderr, format, args); (void) putc ('\n', stderr); va_end (args); /* Delete the output file, if it exists. This will prevent make from thinking that a file was created and hence does not need rebuilding. */ if (out_file_name != NULL) unlink_if_ordinary (out_file_name); xexit (EXIT_FAILURE); }
FILE * bfd_open_file (bfd *abfd) { abfd->cacheable = TRUE; /* Allow it to be closed later. */ if (open_files >= BFD_CACHE_MAX_OPEN) { if (! close_one ()) return NULL; } switch (abfd->direction) { case read_direction: case no_direction: abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_RB); break; case both_direction: case write_direction: if (abfd->opened_once) { abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_RUB); if (abfd->iostream == NULL) abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_WUB); } else { /* Create the file. Some operating systems won't let us overwrite a running binary. For them, we want to unlink the file first. However, gcc 2.95 will create temporary files using O_EXCL and tight permissions to prevent other users from substituting other .o files during the compilation. gcc will then tell the assembler to use the newly created file as an output file. If we unlink the file here, we open a brief window when another user could still substitute a file. So we unlink the output file if and only if it has non-zero size. */ #ifndef __MSDOS__ /* Don't do this for MSDOS: it doesn't care about overwriting a running binary, but if this file is already open by another BFD, we will be in deep trouble if we delete an open file. In fact, objdump does just that if invoked with the --info option. */ struct stat s; if (stat (abfd->filename, &s) == 0 && s.st_size != 0) unlink_if_ordinary (abfd->filename); #endif abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_WUB); abfd->opened_once = TRUE; } break; } if (abfd->iostream == NULL) bfd_set_error (bfd_error_system_call); else { if (! bfd_cache_init (abfd)) return NULL; } return (FILE *) abfd->iostream; }