Skip to content

Commit fd1bb8c

Browse files
author
Yeting Kuo
committed
[ShadowCallStack][RISCV] Update shadow stack doc.
1 parent faed2ea commit fd1bb8c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

clang/docs/ShadowCallStack.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ compiled application or the operating system. Integrating the runtime into
5757
the operating system should be preferred since otherwise all thread creation
5858
and destruction would need to be intercepted by the application.
5959

60-
The instrumentation makes use of the platform register ``x18`` on AArch64 and
61-
``x3`` (``gp``) on RISC-V. For simplicity we will refer to this as the
62-
``SCSReg``. On some platforms, ``SCSReg`` is reserved, and on others, it is
63-
designated as a scratch register. This generally means that any code that may
64-
run on the same thread as code compiled with ShadowCallStack must either target
60+
The instrumentation makes use of the platform register ``x18`` on AArch64,
61+
``x3`` (``gp``) on RISC-V without `Zicfiss`_ and ``ssp`` on RISCV with `Zicfiss`_.
62+
For simplicity we will refer to this as the ``SCSReg``. On some platforms,
63+
``SCSReg`` is reserved, and on others, it is designated as a scratch register.
64+
This generally means that any code that may run on the same thread as code compiled with ShadowCallStack must either target
6565
one of the platforms whose ABI reserves ``SCSReg`` (currently Android, Darwin,
6666
Fuchsia and Windows) or be compiled with a flag to reserve that register (e.g.,
6767
``-ffixed-x18``). If absolutely necessary, code compiled without reserving the
@@ -70,6 +70,7 @@ saving the register value temporarily on the stack (`example in Android`_) but
7070
this should be done with care since it risks leaking the shadow call stack
7171
address.
7272

73+
.. _`Zicfiss`: https://github.com/riscv/riscv-cfi/blob/main/cfi_backward.adoc
7374
.. _`example in Android`: https://android-review.googlesource.com/c/platform/frameworks/base/+/803717
7475

7576
Because it requires a dedicated register, the ShadowCallStack feature is
@@ -151,9 +152,10 @@ Usage
151152

152153
To enable ShadowCallStack, just pass the ``-fsanitize=shadow-call-stack`` flag
153154
to both compile and link command lines. On aarch64, you also need to pass
154-
``-ffixed-x18`` unless your target already reserves ``x18``. On RISC-V, ``x3``
155-
(``gp``) is always reserved. It is, however, important to disable GP relaxation
156-
in the linker. This can be done with the ``--no-relax-gp`` flag in GNU ld.
155+
``-ffixed-x18`` unless your target already reserves ``x18``. On RISC-V without
156+
`Zicfiss`_, ``x3`` (``gp``) is always reserved. It is, however, important to
157+
disable GP relaxation in the linker. This can be done with the ``--no-relax-gp``
158+
flag in GNU ld.
157159

158160
Low-level API
159161
-------------

0 commit comments

Comments
 (0)