diff options
author | Jian Cai <jiancai@google.com> | 2020-09-28 15:30:23 -0700 |
---|---|---|
committer | Jian Cai <jiancai@google.com> | 2020-10-02 21:05:30 +0000 |
commit | fb8fd5be362ec7a52dc3be33859d31b0553c1038 (patch) | |
tree | 01a9f910f4faf54b6585c93149aff87035f7c75c | |
parent | 089db6731d948eeff42acf2cd1037ae0253dc65c (diff) | |
download | toolchain-utils-fb8fd5be362ec7a52dc3be33859d31b0553c1038.tar.gz |
compiler_wrapper: enable -mharden-sls=all on aarch64
Migrate straight-line speculation vulnerability.
Link: http://lists.llvm.org/pipermail/llvm-dev/2020-June/142109.html
BUG=chromium:1096302
TEST=https://docs.google.com/spreadsheets/d/1EZbTYUdq2Y6Jpgy5PrCACB3GrInFy0ahI40IPexBZDM/edit#gid=336625829
Change-Id: I35e8f3cce53b86159f1705429774ceb803264f7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2436936
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Jian Cai <jiancai@google.com>
-rw-r--r-- | compiler_wrapper/aarch64_flags.go | 11 | ||||
-rw-r--r-- | compiler_wrapper/aarch64_flags_test.go | 19 | ||||
-rw-r--r-- | compiler_wrapper/compiler_wrapper.go | 1 | ||||
-rw-r--r-- | compiler_wrapper/testutil_test.go | 1 |
4 files changed, 32 insertions, 0 deletions
diff --git a/compiler_wrapper/aarch64_flags.go b/compiler_wrapper/aarch64_flags.go new file mode 100644 index 00000000..a0d05523 --- /dev/null +++ b/compiler_wrapper/aarch64_flags.go @@ -0,0 +1,11 @@ +// Copyright 2020 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package main + +func processAarch64Flags(builder *commandBuilder) { + if builder.target.arch == "aarch64" { + builder.addPreUserArgs("-mharden-sls=all") + } +} diff --git a/compiler_wrapper/aarch64_flags_test.go b/compiler_wrapper/aarch64_flags_test.go new file mode 100644 index 00000000..0cb692e2 --- /dev/null +++ b/compiler_wrapper/aarch64_flags_test.go @@ -0,0 +1,19 @@ +// Copyright 2020 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package main + +import ( + "testing" +) + +func TestAddSlsFlagOnAarch64(t *testing.T) { + withTestContext(t, func(ctx *testContext) { + cmd := ctx.must(callCompiler(ctx, ctx.cfg, + ctx.newCommand(clangAarch64, mainCc))) + if err := verifyArgOrder(cmd, "-mharden-sls=all", mainCc); err != nil { + t.Error(err) + } + }) +} diff --git a/compiler_wrapper/compiler_wrapper.go b/compiler_wrapper/compiler_wrapper.go index aa52dfdc..49ee0eb0 100644 --- a/compiler_wrapper/compiler_wrapper.go +++ b/compiler_wrapper/compiler_wrapper.go @@ -187,6 +187,7 @@ func prepareClangCommand(builder *commandBuilder) (err error) { } builder.addPostUserArgs(builder.cfg.clangPostFlags...) calcCommonPreUserArgs(builder) + processAarch64Flags(builder) return processClangFlags(builder) } diff --git a/compiler_wrapper/testutil_test.go b/compiler_wrapper/testutil_test.go index 21b7169d..8e2377e7 100644 --- a/compiler_wrapper/testutil_test.go +++ b/compiler_wrapper/testutil_test.go @@ -22,6 +22,7 @@ const ( clangAndroid = "./clang" clangTidyAndroid = "./clang-tidy" clangX86_64 = "./x86_64-cros-linux-gnu-clang" + clangAarch64 = "./aarch64-cros-linux-gnu-clang" gccX86_64 = "./x86_64-cros-linux-gnu-gcc" gccX86_64Eabi = "./x86_64-cros-eabi-gcc" gccArmV7 = "./armv7m-cros-linux-gnu-gcc" |