aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2024-11-21 20:03:18 -0500
committerGopher Robot <gobot@golang.org>2024-11-22 14:16:18 +0000
commit00709919d09904b17cfe3bfeb35521cbd3fb04f8 (patch)
treee98368034c8e632060db5b1cd42059fc6559c8e8 /src/cmd/internal/obj
parent4865aadc21acebc8039f914929f03c7042b2ae8d (diff)
downloadgo-00709919d09904b17cfe3bfeb35521cbd3fb04f8.tar.xz
cmd/compile, cmd/link: FIPS fixes for large programs
1. In cmd/internal/obj, only apply the exclusion list to data symbols. Text symbols are always fine since they can use PC-relative relocations. 2. In cmd/link, only skip trampolines for text symbols in the same package with the same type. Before, all text symbols had type STEXT, but now that there are different sections of STEXT, we can only rely on symbols in the same package in the same section being close enough not to need trampolines. Fixes #70379. Change-Id: Ifad2bdd6001ad3b5b23e641127554e9ec374715e Reviewed-on: https://go-review.googlesource.com/c/go/+/631036 Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/internal/obj')
-rw-r--r--src/cmd/internal/obj/fips140.go43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/cmd/internal/obj/fips140.go b/src/cmd/internal/obj/fips140.go
index 326301aa87..35c4cdfcc9 100644
--- a/src/cmd/internal/obj/fips140.go
+++ b/src/cmd/internal/obj/fips140.go
@@ -238,27 +238,30 @@ func (s *LSym) setFIPSType(ctxt *Link) {
// 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.
+ // Text symbols are always okay, since they can use PC-relative relocations,
+ // but some data symbols are not.
+ if s.Type != objabi.STEXT && s.Type != objabi.STEXTFIPS {
+ // Even in the crypto/internal/fips140 packages,
+ // we exclude various Go runtime metadata,
+ // so that it can be allowed to contain data relocations.
+ if strings.Contains(name, ".inittask") ||
+ strings.Contains(name, ".dict") ||
+ strings.Contains(name, ".typeAssert") ||
+ strings.HasSuffix(name, ".arginfo0") ||
+ strings.HasSuffix(name, ".arginfo1") ||
+ strings.HasSuffix(name, ".argliveinfo") ||
+ strings.HasSuffix(name, ".args_stackmap") ||
+ strings.HasSuffix(name, ".opendefer") ||
+ strings.HasSuffix(name, ".stkobj") ||
+ strings.HasSuffix(name, "·f") {
+ return
+ }
- // Even in the crypto/internal/fips140 packages,
- // we exclude various Go runtime metadata,
- // so that it can be allowed to contain data relocations.
- if strings.Contains(name, ".init") ||
- strings.Contains(name, ".dict") ||
- strings.Contains(name, ".typeAssert") ||
- strings.HasSuffix(name, ".arginfo0") ||
- strings.HasSuffix(name, ".arginfo1") ||
- strings.HasSuffix(name, ".argliveinfo") ||
- strings.HasSuffix(name, ".args_stackmap") ||
- strings.HasSuffix(name, ".opendefer") ||
- strings.HasSuffix(name, ".stkobj") ||
- strings.HasSuffix(name, "·f") {
- return
- }
-
- // This symbol is linknamed to go:fipsinfo,
- // so we shouldn't see it, but skip it just in case.
- if s.Name == "crypto/internal/fips140/check.linkinfo" {
- return
+ // This symbol is linknamed to go:fipsinfo,
+ // so we shouldn't see it, but skip it just in case.
+ if s.Name == "crypto/internal/fips140/check.linkinfo" {
+ return
+ }
}
// This is a FIPS symbol! Convert its type to FIPS.