This resolves legacy go binaries crashing the buildid tool when the -w flag is specified.
Fixes #50809
Change-Id: I55a866f285a3c2cebcf2cdbb9cc30e5078e1d18f
GitHub-Last-Rev:
7169a58fd7ba17fdeb8037cef3f50080169dc137
GitHub-Pull-Request: golang/go#53163
Reviewed-on: https://go-review.googlesource.com/c/go/+/409535
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
log.Fatal(err)
}
+ // <= go 1.7 doesn't embed the contentID or actionID, so no slash is present
+ if !strings.Contains(id, "/") {
+ log.Fatalf("%s: build ID is a legacy format...binary too old for this tool", file)
+ }
+
newID := id[:strings.LastIndex(id, "/")] + "/" + buildid.HashToString(hash)
if len(newID) != len(id) {
log.Fatalf("%s: build ID length mismatch %q vs %q", file, id, newID)