When using the new(old) linker but an old(new) object file is
found, give a better error message.
Change-Id: I94786f1a4b527c15c4f5b00457eab60d215a72a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/225457
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
}
r := goobj2.NewReaderFromBytes(roObject, readonly)
if r == nil {
+ if len(roObject) >= 8 && bytes.Equal(roObject[:8], []byte("\x00go114ld")) {
+ log.Fatalf("found object file %s in old format, but -go115newobj is true\nset -go115newobj consistently in all -gcflags, -asmflags, and -ldflags", f.File().Name())
+ }
panic("cannot read object file")
}
localSymVersion := syms.IncVersion()
"bytes"
"cmd/internal/bio"
"cmd/internal/dwarf"
+ "cmd/internal/goobj2"
"cmd/internal/obj"
"cmd/internal/objabi"
"cmd/internal/sys"
var buf [8]uint8
r.readFull(buf[:])
if string(buf[:]) != startmagic {
+ if string(buf[:]) == goobj2.Magic {
+ log.Fatalf("found object file %s in new format, but -go115newobj is false\nset -go115newobj consistently in all -gcflags, -asmflags, and -ldflags", r.pn)
+ }
log.Fatalf("%s: invalid file start %x %x %x %x %x %x %x %x", r.pn, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7])
}