2009-10-09 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Oct 2009 13:24:59 +0000 (13:24 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Oct 2009 13:24:59 +0000 (13:24 +0000)
PR driver/41637
* lto-wrapper.c (ltrans_output_file, flto_out, args_name): New
globals.
(lto_wrapper_exit): New function.
(fatal): Use it.
(fatal_perror): Likewise.
(fork_execute): Use global args_name, do not free it.
(run_gcc): Use global ltrans_output_file, flto_out, do not free them.
* lto-streamer.h: Remove duplicate prototypes.

PR lto/41635
PR lto/41636
lto/
* lto.c (read_cgraph_and_symbols): Do not assert we can open
a file.
* lto-elf.c (init_shdr##BITS): Fix i18n problems.
(init_ehdr##BITS): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152588 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/lto-streamer.h
gcc/lto-wrapper.c
gcc/lto/ChangeLog
gcc/lto/lto-elf.c
gcc/lto/lto.c

index ed31c56..a214221 100644 (file)
@@ -1,5 +1,17 @@
 2009-10-09  Richard Guenther  <rguenther@suse.de>
 
+       PR driver/41637
+       * lto-wrapper.c (ltrans_output_file, flto_out, args_name): New
+       globals.
+       (lto_wrapper_exit): New function.
+       (fatal): Use it.
+       (fatal_perror): Likewise.
+       (fork_execute): Use global args_name, do not free it.
+       (run_gcc): Use global ltrans_output_file, flto_out, do not free them.
+       * lto-streamer.h: Remove duplicate prototypes.
+
+2009-10-09  Richard Guenther  <rguenther@suse.de>
+
        * cgraph.c (cgraph_create_edge): Check for NULL call_stmt
        before calling stmt_can_throw_external.
 
index c4d66b7..4d90ecb 100644 (file)
@@ -806,10 +806,6 @@ extern void lto_check_version (int, int);
 
 
 /* In lto-streamer-in.c */
-extern void lto_input_function_body (struct lto_file_decl_data *, tree,
-                                    const char *);
-extern void lto_input_constructors_and_inits (struct lto_file_decl_data *,
-                                             const char *);
 extern void lto_input_cgraph (struct lto_file_decl_data *, const char *);
 extern void lto_init_reader (void);
 extern tree lto_input_tree (struct lto_input_block *, struct data_in *);
index 228a0a4..cddd415 100644 (file)
@@ -55,6 +55,26 @@ enum lto_mode_d {
 /* Current LTO mode.  */
 static enum lto_mode_d lto_mode = LTO_MODE_NONE;
 
+static char *ltrans_output_file;
+static char *flto_out;
+static char *args_name;
+
+static void maybe_unlink_file (const char *);
+
+/* Delete tempfiles and exit function.  */
+
+static void
+lto_wrapper_exit (int status)
+{
+  if (ltrans_output_file)
+    maybe_unlink_file (ltrans_output_file);
+  if (flto_out)
+    maybe_unlink_file (flto_out);
+  if (args_name)
+    maybe_unlink_file (args_name);
+  exit (status);
+}
+
 /* Just die. CMSGID is the error message. */
 
 static void __attribute__ ((format (printf, 1, 2)))
@@ -68,7 +88,7 @@ fatal (const char * cmsgid, ...)
   fprintf (stderr, "\n");
   va_end (ap);
 
-  exit (FATAL_EXIT_CODE);
+  lto_wrapper_exit (FATAL_EXIT_CODE);
 }
 
 
@@ -86,7 +106,7 @@ fatal_perror (const char *cmsgid, ...)
   fprintf (stderr, ": %s\n", xstrerror (e));
   va_end (ap);
 
-  exit (FATAL_EXIT_CODE);
+  lto_wrapper_exit (FATAL_EXIT_CODE);
 }
 
 
@@ -190,11 +210,13 @@ fork_execute (char **argv)
 {
   struct pex_obj *pex;
   char *new_argv[3];
-  char *args_name = make_temp_file (".args");
-  char *at_args = concat ("@", args_name, NULL);
-  FILE *args = fopen (args_name, "w");
+  char *at_args;
+  FILE *args;
   int status;
 
+  args_name = make_temp_file (".args");
+  at_args = concat ("@", args_name, NULL);
+  args = fopen (args_name, "w");
   if (args == NULL)
     fatal ("failed to open %s", args_name);
 
@@ -213,7 +235,6 @@ fork_execute (char **argv)
   collect_wait (new_argv[0], pex);
 
   maybe_unlink_file (args_name);
-  free (args_name);
   free (at_args);
 }
 
@@ -227,8 +248,6 @@ run_gcc (unsigned argc, char *argv[])
   unsigned new_argc = argc;
   const char **new_argv;
   const char **argv_ptr;
-  char *ltrans_output_file = NULL;
-  char *flto_out = NULL;
   char *list_option_full = NULL;
 
   new_argc += 8;
@@ -320,7 +339,6 @@ run_gcc (unsigned argc, char *argv[])
        putc (c, stdout);
       fclose (stream);
       maybe_unlink_file (ltrans_output_file);
-      free (ltrans_output_file);
       free (list_option_full);
     }
   else
index f2eb1a2..82b8bec 100644 (file)
@@ -1,3 +1,12 @@
+2009-10-09  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/41635
+       PR lto/41636
+       * lto.c (read_cgraph_and_symbols): Do not assert we can open
+       a file.
+       * lto-elf.c (init_shdr##BITS): Fix i18n problems.
+       (init_ehdr##BITS): Likewise.
+
 2009-10-08  Joseph Myers  <joseph@codesourcery.com>
 
        * lto-elf.c (init_shdr##BITS, lto_elf_begin_section_with_type,
index 28c26c7..190430b 100644 (file)
@@ -235,7 +235,12 @@ init_shdr##BITS (Elf_Scn *scn, size_t sh_name, size_t sh_type)           \
                                                                      \
   shdr = elf##BITS##_getshdr (scn);                                  \
   if (!shdr)                                                         \
-    fatal_error ("elf"#BITS"_getshdr() failed: %s", elf_errmsg (-1));\
+    {                                                                \
+      if (BITS == 32)                                                \
+       fatal_error ("elf32_getshdr() failed: %s", elf_errmsg (-1));  \
+      else                                                           \
+       fatal_error ("elf64_getshdr() failed: %s", elf_errmsg (-1));  \
+    }                                                                \
                                                                      \
   shdr->sh_name = sh_name;                                           \
   shdr->sh_type = sh_type;                                           \
@@ -486,7 +491,12 @@ init_ehdr##BITS (lto_elf_file *elf_file)                         \
                                                                      \
   ehdr = elf##BITS##_newehdr (elf_file->elf);                        \
   if (!ehdr)                                                         \
-    fatal_error ("elf"#BITS"_newehdr() failed: %s", elf_errmsg (-1));\
+    {                                                                \
+      if (BITS == 32)                                                \
+       fatal_error ("elf32_newehdr() failed: %s", elf_errmsg (-1));  \
+      else                                                           \
+       fatal_error ("elf64_newehdr() failed: %s", elf_errmsg (-1));  \
+    }                                                                \
                                                                      \
   memcpy (ehdr->e_ident, cached_file_attrs.elf_ident,                \
          sizeof cached_file_attrs.elf_ident);                        \
index cc40091..2b674c1 100644 (file)
@@ -1779,7 +1779,10 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
       unsigned num_objects;
 
       resolution = fopen (resolution_file_name, "r");
-      gcc_assert (resolution != NULL);
+      if (resolution == NULL)
+       fatal_error ("could not open symbol resolution file: %s",
+                    xstrerror (errno));
+
       t = fscanf (resolution, "%u", &num_objects);
       gcc_assert (t == 1);