Change information
Commit message:
cmd/compile: don't treat string literal as static data in FIPS mode
Reference a string literal requires a relocation, which is not
allowed in static data in FIPS mode, as this would be an absolute
relocation, and cannot be properly hashed at both link time and
run time.
Also, make sure the symbol's FIPS type is set before writing.
This ensures relocations are checked in FIPS RODATA symbols.
Currently we only call setFIPSType in prewrite if we change the
type from a BSS type to a DATA type. But it is possible that the
compiler sets the symbol type to RODATA and start writing to it.
For #78173.
Change-Id: I120a3b28ee3f38e9024479344565f54dff87d430
Files:
- M src/cmd/compile/internal/walk/complit.go
- M src/cmd/internal/obj/data.go
- A src/crypto/internal/fips140/compile_test.go
Change size: S
Delta: 3 files changed, 32 insertions(+), 3 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Russ Cox
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI