Commit 5958009b by Andi Kleen Committed by Andi Kleen

Add error checking to lto_section_read

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
parent b74bdc61
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> 2011-10-11 Michael Meissner <meissner@linux.vnet.ibm.com>
* lto-lang.c (def_builtin_1): Delete old interface with two * lto-lang.c (def_builtin_1): Delete old interface with two
......
...@@ -1237,7 +1237,10 @@ lto_read_section_data (struct lto_file_decl_data *file_data, ...@@ -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); fd = open (file_data->file_name, O_RDONLY|O_BINARY);
if (fd == -1) if (fd == -1)
{
fatal_error ("Cannot open %s", file_data->file_name);
return NULL; return NULL;
}
fd_name = xstrdup (file_data->file_name); fd_name = xstrdup (file_data->file_name);
} }
...@@ -1255,7 +1258,10 @@ lto_read_section_data (struct lto_file_decl_data *file_data, ...@@ -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, result = (char *) mmap (NULL, computed_len, PROT_READ, MAP_PRIVATE,
fd, computed_offset); fd, computed_offset);
if (result == MAP_FAILED) if (result == MAP_FAILED)
{
fatal_error ("Cannot map %s", file_data->file_name);
return NULL; return NULL;
}
return result + diff; return result + diff;
#else #else
...@@ -1264,6 +1270,7 @@ lto_read_section_data (struct lto_file_decl_data *file_data, ...@@ -1264,6 +1270,7 @@ lto_read_section_data (struct lto_file_decl_data *file_data,
|| read (fd, result, len) != (ssize_t) len) || read (fd, result, len) != (ssize_t) len)
{ {
free (result); free (result);
fatal_error ("Cannot read %s", file_data->file_name);
result = NULL; result = NULL;
} }
#ifdef __MINGW32__ #ifdef __MINGW32__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment