mirror of
https://github.com/golang/go
synced 2024-11-22 20:24:47 -07:00
cmd/compile: avoid static init of strings in FIPS mode
Strings have relocations, and data relocations are bad. Other literals are fine. Fixes build failure in pending CL 628776. Change-Id: I7a38bbff9776a365c5823d54c4a00e068dda5d9a Reviewed-on: https://go-review.googlesource.com/c/go/+/628915 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
61790207f5
commit
5ec1457941
@ -332,6 +332,9 @@ func (s *Schedule) StaticAssign(l *ir.Name, loff int64, r ir.Node, typ *types.Ty
|
|||||||
if ir.IsZero(r) {
|
if ir.IsZero(r) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if disableGlobalAddrs && r.Type().IsString() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
staticdata.InitConst(l, loff, r, int(typ.Size()))
|
staticdata.InitConst(l, loff, r, int(typ.Size()))
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
@ -85,7 +85,9 @@ const (
|
|||||||
func getdyn(n ir.Node, top bool) initGenType {
|
func getdyn(n ir.Node, top bool) initGenType {
|
||||||
switch n.Op() {
|
switch n.Op() {
|
||||||
default:
|
default:
|
||||||
if ir.IsConstNode(n) {
|
// Handle constants in linker, except that linker cannot do
|
||||||
|
// the relocations necessary for string constants in FIPS packages.
|
||||||
|
if ir.IsConstNode(n) && (!n.Type().IsString() || !base.Ctxt.IsFIPS()) {
|
||||||
return initConst
|
return initConst
|
||||||
}
|
}
|
||||||
return initDynamic
|
return initDynamic
|
||||||
|
Loading…
Reference in New Issue
Block a user