cmd/link: make -f flag actually ignore version mismatch

The linker's -f flag is documented as "ignore version mismatch",
but it currently does not. Make it so.

Change-Id: Ieb16acf35f75a2eb9d674bb3a1bd9fd01363867e
Reviewed-on: https://go-review.googlesource.com/c/go/+/770680
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Cherry Mui 2026-04-24 21:45:04 -04:00
parent 8191cd8868
commit cbaecb2830

View file

@ -2512,7 +2512,7 @@ func ldobj(ctxt *Link, f *bio.Reader, lib *sym.Library, length int64, pn string,
}
// First, check that the basic GOOS, GOARCH, and Version match.
if line != wantHdr {
if line != wantHdr && !*flagF {
Errorf("%s: linked object header mismatch:\nhave %q\nwant %q\n", pn, line, wantHdr)
}