http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #12 from Anders F Björklund <afb at users dot sourceforge.net> 
2011-09-02 11:07:33 UTC ---
> It doesn't include the objcopy header,
> but I believe that is skipped anyway ?

Or at least it was *supposed* to ignore it,
but the Stream_from_file was horribly buggy.
(apparently has a dyslectic problem with
comparisons, aggrevated by copy/paste ?)

It always returned "" instead of any data,
so failed to provide the required magic...
(or any other data beyond that, if asked)
Fixing that class, and it works just fine:

Index: gcc/go/gofrontend/import.cc
===================================================================
--- gcc/go/gofrontend/import.cc    (revision 178444)
+++ gcc/go/gofrontend/import.cc    (working copy)
@@ -836,7 +836,7 @@
 bool
 Stream_from_file::do_peek(size_t length, const char** bytes)
 {
-  if (this->data_.length() <= length)
+  if (this->data_.length() >= length)
     {
       *bytes = this->data_.data();
       return true;
@@ -854,7 +854,7 @@
       return false;
     }

-  if (lseek(this->fd_, - got, SEEK_CUR) != 0)
+  if (lseek(this->fd_, - got, SEEK_CUR) < 0)
     {
       if (!this->saw_error())
     error("lseek failed: %m");
@@ -876,7 +876,7 @@
 void
 Stream_from_file::do_advance(size_t skip)
 {
-  if (lseek(this->fd_, skip, SEEK_CUR) != 0)
+  if (lseek(this->fd_, skip, SEEK_CUR) < 0)
     {
       if (!this->saw_error())
     error("lseek failed: %m");

That bug should affect any other platform too,
if trying to use "naked" .gox (without object) ?

Reply via email to