]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add error checking to lto_section_read
authorAndi Kleen <ak@linux.intel.com>
Sun, 16 Oct 2011 23:22:32 +0000 (23:22 +0000)
committerAndi Kleen <ak@gcc.gnu.org>
Sun, 16 Oct 2011 23:22:32 +0000 (23:22 +0000)
gcc/lto/:

2011-10-09  Andi Kleen  <ak@linux.intel.com>

* lto.c (lto_section_read): Call fatal_error on IO or mmap errors.

From-SVN: r180065

gcc/lto/ChangeLog
gcc/lto/lto.c

index e350fd83b054729e9d70e27ff9901fa29e8fe2b0..12f75ada5b76ae34167ecc54f9c9f6efef88634c 100644 (file)
@@ -1,3 +1,7 @@
+2011-10-09  Andi Kleen  <ak@linux.intel.com>
+
+       * lto.c (lto_section_read): Call fatal_error on IO or mmap errors.
+
 2011-10-11  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        * lto-lang.c (def_builtin_1): Delete old interface with two
index a77eeb48c55505fdb99c5b22b854dff1571a8333..63af047640d68fa14205a11d8a90bf776b17c7fd 100644 (file)
@@ -1237,7 +1237,10 @@ lto_read_section_data (struct lto_file_decl_data *file_data,
     {
       fd = open (file_data->file_name, O_RDONLY|O_BINARY);
       if (fd == -1)
-       return NULL;
+        {
+         fatal_error ("Cannot open %s", file_data->file_name);
+         return NULL;
+        }
       fd_name = xstrdup (file_data->file_name);
     }
 
@@ -1255,7 +1258,10 @@ lto_read_section_data (struct lto_file_decl_data *file_data,
   result = (char *) mmap (NULL, computed_len, PROT_READ, MAP_PRIVATE,
                          fd, computed_offset);
   if (result == MAP_FAILED)
-    return NULL;
+    {
+      fatal_error ("Cannot map %s", file_data->file_name);
+      return NULL;
+    }
 
   return result + diff;
 #else
@@ -1264,6 +1270,7 @@ lto_read_section_data (struct lto_file_decl_data *file_data,
       || read (fd, result, len) != (ssize_t) len)
     {
       free (result);
+      fatal_error ("Cannot read %s", file_data->file_name);
       result = NULL;
     }
 #ifdef __MINGW32__