This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gccgo] Fix importing an archive


When I switched gccgo to use the simple_object interface I forgot that
simple_object_start_read can change the file offset.  That broke reading
Go export data from an archive file.  This patch fixes it.  Committed to
gccgo branch.

Ian

diff -r 1cf52af24e94 go/import.cc
--- a/go/import.cc	Tue Nov 16 14:37:12 2010 -0800
+++ b/go/import.cc	Tue Nov 16 16:19:15 2010 -0800
@@ -192,6 +192,13 @@
 
   const int len = MAX(Export::v1_magic_len, Import::archive_magic_len);
 
+  if (lseek(fd, 0, SEEK_SET) < 0)
+    {
+      error_at(location, "lseek %s failed: %s", filename.c_str(),
+	       strerror(errno));
+      return NULL;
+    }
+
   char buf[len];
   ssize_t c = read(fd, buf, len);
   if (c < len)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]