Skip to content

Commit 309f864

Browse files
committed
[Gardening] De-RST libFuzzerIntegration
1 parent 5b83661 commit 309f864

File tree

3 files changed

+37
-38
lines changed

3 files changed

+37
-38
lines changed

docs/contents.rst

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Contents
1616
SIL
1717
TypeChecker
1818
OptimizationTips
19-
libFuzzerIntegration
2019
ABI: TypeMetadata <ABI/TypeMetadata>
2120
ABI: TypeLayout <ABI/TypeLayout>
2221
ABI: Mangling <ABI/Mangling>

docs/libFuzzerIntegration.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
libFuzzer Integration
2+
---------------------
3+
4+
Swift compiler comes with a built-in `libFuzzer` integration.
5+
In order to use it on a file `myfile.swift`, we define an entry point fuzzing function
6+
with a `@_cdecl("LLVMFuzzerTestOneInput")` annotation:
7+
8+
9+
```swift
10+
@_cdecl("LLVMFuzzerTestOneInput") public func fuzzMe(Data: UnsafePointer<CChar>, Size: CInt) -> CInt{
11+
// Test our code using provided Data.
12+
}
13+
}
14+
```
15+
16+
To compile it, we use `-sanitize=fuzzer` flag to link `libFuzzer`
17+
and enable coverage annotation, and `-parse-as-library` flag not to insert
18+
the `main` symbol, such that the fuzzer entry point can be used:
19+
20+
```bash
21+
% swiftc -sanitize=fuzzer -parse-as-library myfile.swift
22+
```
23+
24+
`libFuzzer` can be also combined with other sanitizers:
25+
26+
```bash
27+
% swiftc -sanitize=fuzzer,address -parse-as-library myfile.swift
28+
```
29+
30+
Finally, we launch the fuzzing process:
31+
32+
```bash
33+
% ./a.out
34+
```
35+
36+
Refer to the official `libFuzzer` documentation at http://llvm.org/docs/LibFuzzer.html
37+
for the description of flags the resulting binary has.

docs/libFuzzerIntegration.rst

-37
This file was deleted.

0 commit comments

Comments
 (0)