mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/asm, cmd/compile, runtime: add -spectre=ret mode
This commit extends the -spectre flag to cmd/asm and adds a new Spectre mitigation mode "ret", which enables the use of retpolines. Retpolines prevent speculation about the target of an indirect jump or call and are described in more detail here: https://support.google.com/faqs/answer/7625886 Change-Id: I4f2cb982fa94e44d91e49bd98974fd125619c93a Reviewed-on: https://go-review.googlesource.com/c/go/+/222661 Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
877ef86bec
commit
fc8a6336d1
13 changed files with 119 additions and 1 deletions
|
|
@ -41,6 +41,19 @@ func main() {
|
|||
ctxt.Flag_dynlink = *flags.Dynlink
|
||||
ctxt.Flag_shared = *flags.Shared || *flags.Dynlink
|
||||
ctxt.Flag_newobj = *flags.Newobj
|
||||
switch *flags.Spectre {
|
||||
default:
|
||||
log.Printf("unknown setting -spectre=%s", *flags.Spectre)
|
||||
os.Exit(2)
|
||||
case "":
|
||||
// nothing
|
||||
case "index":
|
||||
// known to compiler; ignore here so people can use
|
||||
// the same list with -gcflags=-spectre=LIST and -asmflags=-spectrre=LIST
|
||||
case "all", "ret":
|
||||
ctxt.Retpoline = true
|
||||
}
|
||||
|
||||
ctxt.Bso = bufio.NewWriter(os.Stdout)
|
||||
defer ctxt.Bso.Flush()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue