Skip to content

Commit 3ad6403

Browse files
authored
[Clang][RISCV] Remove forced-sw-shadow-stack (#115355)
This option was used to override the behavior of `-fsanitize=shadowcallstack` on RISC-V backend, which by default use a hardware implementation if possible, to use the software implementation instead. After #112477 and #112478, now two implementation is represented by independent options and we no longer need it.
1 parent b613a54 commit 3ad6403

File tree

3 files changed

+4
-15
lines changed

3 files changed

+4
-15
lines changed

clang/docs/ShadowCallStack.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@ 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 ``-mno-forced-sw-shadow-stack``
63-
(default option). Note that with ``Zicfiss``_ the RISC-V backend will default to
64-
the hardware based shadow call stack. Users can force the RISC-V backend to
65-
generate the software shadow call stack with ``Zicfiss``_ by passing
66-
``-mforced-sw-shadow-stack``.
62+
hardware shadow stack, which needs `Zicfiss`_ and ``-fcf-protection=return``.
63+
Users can choose between the software and hardware based shadow stack
64+
implementation on RISC-V backend by passing ``-fsanitize=shadowcallstack``
65+
or ``Zicfiss`` with ``-fcf-protection=return``.
6766
For simplicity we will refer to this as the ``SCSReg``. On some platforms,
6867
``SCSReg`` is reserved, and on others, it is designated as a scratch register.
6968
This generally means that any code that may run on the same thread as code

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4930,10 +4930,6 @@ def msave_restore : Flag<["-"], "msave-restore">, Group<m_riscv_Features_Group>,
49304930
HelpText<"Enable using library calls for save and restore">;
49314931
def mno_save_restore : Flag<["-"], "mno-save-restore">, Group<m_riscv_Features_Group>,
49324932
HelpText<"Disable using library calls for save and restore">;
4933-
def mforced_sw_shadow_stack : Flag<["-"], "mforced-sw-shadow-stack">, Group<m_riscv_Features_Group>,
4934-
HelpText<"Force using software shadow stack when shadow-stack enabled">;
4935-
def mno_forced_sw_shadow_stack : Flag<["-"], "mno-forced-sw-shadow-stack">, Group<m_riscv_Features_Group>,
4936-
HelpText<"Not force using software shadow stack when shadow-stack enabled">;
49374933
} // let Flags = [TargetSpecific]
49384934
let Flags = [TargetSpecific] in {
49394935
def menable_experimental_extensions : Flag<["-"], "menable-experimental-extensions">, Group<m_Group>,

clang/test/Driver/riscv-features.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@
2929
// DEFAULT-NOT: "-target-feature" "-save-restore"
3030
// DEFAULT-NOT: "-target-feature" "+save-restore"
3131

32-
// RUN: %clang --target=riscv32-unknown-elf -### %s -mforced-sw-shadow-stack 2>&1 | FileCheck %s -check-prefix=FORCE-SW-SCS
33-
// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-forced-sw-shadow-stack 2>&1 | FileCheck %s -check-prefix=NO-FORCE-SW-SCS
34-
// FORCE-SW-SCS: "-target-feature" "+forced-sw-shadow-stack"
35-
// NO-FORCE-SW-SCS: "-target-feature" "-forced-sw-shadow-stack"
36-
// DEFAULT-NOT: "-target-feature" "+forced-sw-shadow-stack"
37-
3832
// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-strict-align 2>&1 | FileCheck %s -check-prefixes=FAST-SCALAR-UNALIGNED-ACCESS,FAST-VECTOR-UNALIGNED-ACCESS
3933
// RUN: %clang --target=riscv32-unknown-elf -### %s -mstrict-align 2>&1 | FileCheck %s -check-prefixes=NO-FAST-SCALAR-UNALIGNED-ACCESS,NO-FAST-VECTOR-UNALIGNED-ACCESS
4034
// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-scalar-strict-align 2>&1 | FileCheck %s -check-prefix=FAST-SCALAR-UNALIGNED-ACCESS

0 commit comments

Comments
 (0)