]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: prevent 387+float32+pie from clobbering registers
authorKeith Randall <khr@golang.org>
Thu, 24 Sep 2020 21:25:21 +0000 (14:25 -0700)
committerKeith Randall <khr@golang.org>
Thu, 24 Sep 2020 22:45:05 +0000 (22:45 +0000)
commitea106cc07ac73110a8a25fcc5aef07b283159db0
tree0af5022d7061bbff95e12fcf47a18f9e38293709
parentf765dcbd5c8205a0d222257b4514b1194cad26f8
cmd/compile: prevent 387+float32+pie from clobbering registers

The 387 port needs to load a floating-point control word from a
global location to implement float32 arithmetic.
When compiling with -pie, loading that control word clobbers an
integer register. If that register had something important in it, boom.

Fix by using LEAL to materialize the address of the global location
first. LEAL with -pie works because the destination register is
used as the scratch register.

387 support is about to go away (#40255), so this will need to be
backported to have any effect.

No test. I have one, but it requires building with -pie, which
requires cgo. Our testing infrastructure doesn't make that easy.
Not worth it for a port which is about to vanish.

Fixes #41503

Change-Id: I140f9fc8fdce4e74a52c2c046e2bd30ae476d295
Reviewed-on: https://go-review.googlesource.com/c/go/+/257277
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Keith Randall <khr@golang.org>
src/cmd/compile/internal/x86/387.go