File tree 3 files changed +37
-38
lines changed
3 files changed +37
-38
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ Contents
16
16
SIL
17
17
TypeChecker
18
18
OptimizationTips
19
- libFuzzerIntegration
20
19
ABI: TypeMetadata <ABI/TypeMetadata >
21
20
ABI: TypeLayout <ABI/TypeLayout >
22
21
ABI: Mangling <ABI/Mangling >
Original file line number Diff line number Diff line change
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.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments