]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.15] 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)
committerAndrew Bonventre <andybons@golang.org>
Thu, 1 Oct 2020 18:28:30 +0000 (18:28 +0000)
commitfa262e61fd8e123c53023c122ab6330a8ae28aa3
tree7d947a0ed7544b9e8d3c4098403972f4837447f7
parentfa01c8a14eeb760c58c5cd09afec327fdd392b2c
[release-branch.go1.15] 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 #41620

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>
(cherry picked from commit ea106cc07ac73110a8a25fcc5aef07b283159db0)
Reviewed-on: https://go-review.googlesource.com/c/go/+/257207
src/cmd/compile/internal/x86/387.go