Skip to content

Commit 7675d7a

Browse files
committed
sembr sanitizers.md
1 parent 191778d commit 7675d7a

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

src/doc/rustc-dev-guide/src/sanitizers.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,24 @@ The rustc compiler contains support for following sanitizers:
1010
* [Hardware-assisted AddressSanitizer][clang-hwasan] a tool similar to
1111
AddressSanitizer but based on partial hardware assistance.
1212
* [KernelControlFlowIntegrity][clang-kcfi] LLVM Kernel Control Flow Integrity
13-
(KCFI) provides forward-edge control flow protection for operating systems
14-
kernels.
13+
(KCFI) provides forward-edge control flow protection for operating systems kernels.
1514
* [LeakSanitizer][clang-lsan] a run-time memory leak detector.
1615
* [MemorySanitizer][clang-msan] a detector of uninitialized reads.
1716
* [ThreadSanitizer][clang-tsan] a fast data race detector.
1817

1918
## How to use the sanitizers?
2019

2120
To enable a sanitizer compile with `-Z sanitizer=...` option, where value is one
22-
of `address`, `cfi`, `hwaddress`, `kcfi`, `leak`, `memory` or `thread`. For more
23-
details on how to use sanitizers please refer to the sanitizer flag in [the
21+
of `address`, `cfi`, `hwaddress`, `kcfi`, `leak`, `memory` or `thread`.
22+
For more details on how to use sanitizers please refer to the sanitizer flag in [the
2423
unstable book](https://doc.rust-lang.org/unstable-book/).
2524

2625
## How are sanitizers implemented in rustc?
2726

2827
The implementation of sanitizers (except CFI) relies almost entirely on LLVM.
2928
The rustc is an integration point for LLVM compile time instrumentation passes
30-
and runtime libraries. Highlight of the most important aspects of the
31-
implementation:
29+
and runtime libraries.
30+
Highlight of the most important aspects of the implementation:
3231

3332
* The sanitizer runtime libraries are part of the [compiler-rt] project, and
3433
[will be built][sanitizer-build] on [supported targets][sanitizer-targets]
@@ -43,23 +42,26 @@ implementation:
4342

4443
* During LLVM code generation, the functions intended for instrumentation are
4544
[marked][sanitizer-attribute] with appropriate LLVM attribute:
46-
`SanitizeAddress`, `SanitizeHWAddress`, `SanitizeMemory`, or
47-
`SanitizeThread`. By default all functions are instrumented, but this
45+
`SanitizeAddress`, `SanitizeHWAddress`, `SanitizeMemory`, or `SanitizeThread`.
46+
By default all functions are instrumented, but this
4847
behaviour can be changed with `#[sanitize(xyz = "on|off|<other>")]`.
4948

5049
* The decision whether to perform instrumentation or not is possible only at a
51-
function granularity. In the cases were those decision differ between
50+
function granularity.
51+
In the cases were those decision differ between
5252
functions it might be necessary to inhibit inlining, both at [MIR
5353
level][inline-mir] and [LLVM level][inline-llvm].
5454

5555
* The LLVM IR generated by rustc is instrumented by [dedicated LLVM
56-
passes][sanitizer-pass], different for each sanitizer. Instrumentation
57-
passes are invoked after optimization passes.
56+
passes][sanitizer-pass], different for each sanitizer.
57+
Instrumentation passes are invoked after optimization passes.
5858

5959
* When producing an executable, the sanitizer specific runtime library is
60-
[linked in][sanitizer-link]. The libraries are searched for in the target
61-
libdir. First relative to the overridden system root and subsequently
62-
relative to the default system root. Fall-back to the default system root
60+
[linked in][sanitizer-link].
61+
The libraries are searched for in the target libdir.
62+
First relative to the overridden system root and subsequently
63+
relative to the default system root.
64+
Fall-back to the default system root
6365
ensures that sanitizer runtimes remain available when using sysroot overrides
6466
constructed by cargo `-Z build-std` or xargo.
6567

@@ -80,10 +82,9 @@ Sanitizers are validated by code generation tests in
8082
[`tests/ui/sanitizer/`][test-ui] directory.
8183

8284
Testing sanitizer functionality requires the sanitizer runtimes (built when
83-
`sanitizer = true` in `bootstrap.toml`) and target providing support for particular
84-
sanitizer. When sanitizer is unsupported on given target, sanitizers tests will
85-
be ignored. This behaviour is controlled by compiletest `needs-sanitizer-*`
86-
directives.
85+
`sanitizer = true` in `bootstrap.toml`) and target providing support for particular sanitizer.
86+
When sanitizer is unsupported on given target, sanitizers tests will be ignored.
87+
This behaviour is controlled by compiletest `needs-sanitizer-*` directives.
8788

8889
[test-cg]: https://github.com/rust-lang/rust/tree/HEAD/tests/codegen-llvm
8990
[test-ui]: https://github.com/rust-lang/rust/tree/HEAD/tests/ui/sanitizer
@@ -93,8 +94,8 @@ directives.
9394
To enable a sanitizer on a new target which is already supported by LLVM:
9495

9596
1. Include the sanitizer in the list of `supported_sanitizers` in [the target
96-
definition][target-definition]. `rustc --target .. -Zsanitizer=..` should now
97-
recognize sanitizer as supported.
97+
definition][target-definition].
98+
`rustc --target .. -Zsanitizer=..` should now recognize sanitizer as supported.
9899
2. [Build the runtime for the target and include it in the libdir.][sanitizer-targets]
99100
3. [Teach compiletest that your target now supports the sanitizer.][compiletest-definition]
100101
Tests marked with `needs-sanitizer-*` should now run on the target.

0 commit comments

Comments
 (0)