// IsFIPS reports whether we are compiling one of the crypto/internal/fips/... packages.
func (ctxt *Link) IsFIPS() bool {
+ if strings.HasSuffix(ctxt.Pkgpath, "_test") {
+ // External test packages are outside the FIPS hash scope.
+ // This allows them to use //go:embed, which would otherwise
+ // emit absolute relocations in the global data.
+ return false
+ }
return ctxt.Pkgpath == "crypto/internal/fips" || strings.HasPrefix(ctxt.Pkgpath, "crypto/internal/fips/")
}
return
}
+ if strings.Contains(name, "_test.") {
+ // External test packages are not in the scope.
+ return
+ }
+
// Now we're at least handling a FIPS symbol.
// It's okay to be slower now, since this code only runs when compiling a few packages.