Skip to content

Commit 82411aa

Browse files
author
Yeting Kuo
committed
Add option -{m,mno}-forced-sw-shadow-stack
1 parent f99f73f commit 82411aa

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

clang/docs/ShadowCallStack.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ and destruction would need to be intercepted by the application.
5959

6060
The instrumentation makes use of the platform register ``x18`` on AArch64,
6161
``x3`` (``gp``) on RISC-V with software shadow stack and ``ssp`` on RISC-V with
62-
hardware shadow stack, which needs `Zicfiss`_ and ``-mllvm -riscv-hardware-shadow-stack``.
62+
hardware shadow stack, which needs `Zicfiss`_ and ``-mno-forced-sw-shadow-stack``
63+
(default option). ``-mforced-sw-shadow-stack`` make risc-v backend generate
64+
software shadow stack with `Zicfiss`_ when shadow stack enabled.
6365
For simplicity we will refer to this as the ``SCSReg``. On some platforms,
6466
``SCSReg`` is reserved, and on others, it is designated as a scratch register.
6567
This generally means that any code that may run on the same thread as code compiled with ShadowCallStack must either target

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4578,6 +4578,10 @@ def msave_restore : Flag<["-"], "msave-restore">, Group<m_riscv_Features_Group>,
45784578
HelpText<"Enable using library calls for save and restore">;
45794579
def mno_save_restore : Flag<["-"], "mno-save-restore">, Group<m_riscv_Features_Group>,
45804580
HelpText<"Disable using library calls for save and restore">;
4581+
def mforced_sw_shadow_stack : Flag<["-"], "mforced-sw-shadow-stack">, Group<m_riscv_Features_Group>,
4582+
HelpText<"Force using software shadow stack when shadow-stack enabled">;
4583+
def mno_forced_sw_shadow_stack : Flag<["-"], "mno-forced-sw-shadow-stack">, Group<m_riscv_Features_Group>,
4584+
HelpText<"Not force using software shadow stack when shadow-stack enabled">;
45814585
} // let Flags = [TargetSpecific]
45824586
let Flags = [TargetSpecific] in {
45834587
def menable_experimental_extensions : Flag<["-"], "menable-experimental-extensions">, Group<m_Group>,

clang/test/Driver/riscv-features.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
// DEFAULT-NOT: "-target-feature" "-save-restore"
2828
// DEFAULT-NOT: "-target-feature" "+save-restore"
2929

30+
// RUN: %clang --target=riscv32-unknown-elf -### %s -mforced-sw-shadow-stack 2>&1 | FileCheck %s -check-prefix=FORCE-SW-SCS
31+
// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-forced-sw-shadow-stack 2>&1 | FileCheck %s -check-prefix=NO-FORCE-SW-SCS
32+
// FORCE-SW-SCS: "-target-feature" "+forced-sw-shadow-stack"
33+
// NO-FORCE-SW-SCS: "-target-feature" "-forced-sw-shadow-stack"
34+
3035
// RUN: %clang --target=riscv32-unknown-elf -### %s -munaligned-access 2>&1 | FileCheck %s -check-prefix=FAST-UNALIGNED-ACCESS
3136
// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-unaligned-access 2>&1 | FileCheck %s -check-prefix=NO-FAST-UNALIGNED-ACCESS
3237
// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-strict-align 2>&1 | FileCheck %s -check-prefix=FAST-UNALIGNED-ACCESS

0 commit comments

Comments
 (0)