-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f65b284
Showing
7 changed files
with
299 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.zig text eol=lf | ||
*.zon text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Continuous Integration | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
pull_request: | ||
branches: [main] | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
exes: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Zig | ||
uses: mlugg/setup-zig@v1 | ||
|
||
- name: Run `exes` | ||
run: zig build exes | ||
|
||
fmt: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Zig | ||
uses: mlugg/setup-zig@v1 | ||
|
||
- name: Run `fmt` | ||
run: zig build fmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
kcov-output/ | ||
.zig-cache/ | ||
zig-out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Jora Troosh | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# AFLplusplus | ||
|
||
[![CI][ci-shd]][ci-url] | ||
[![LC][lc-shd]][lc-url] | ||
|
||
## Zig build of [AFLplusplus executable suite](https://github.com/AFLplusplus/AFLplusplus). | ||
|
||
### :rocket: Usage | ||
|
||
```sh | ||
git clone https://github.com/allyourcodebase/AFLplusplus.git | ||
cd AFLplusplus/ | ||
zig build exes -Doptimize=ReleaseFast | ||
./zig-out/bin/afl-fuzz | ||
./zig-out/bin/afl-showmap | ||
./zig-out/bin/afl-tmin | ||
./zig-out/bin/afl-analyze | ||
./zig-out/bin/afl-gotcpu | ||
./zig-out/bin/afl-as | ||
``` | ||
|
||
<!-- MARKDOWN LINKS --> | ||
|
||
[ci-shd]: https://img.shields.io/github/actions/workflow/status/allyourcodebase/AFLplusplus/ci.yaml?branch=main&style=for-the-badge&logo=github&label=CI&labelColor=black | ||
[ci-url]: https://github.com/allyourcodebase/AFLplusplus/blob/main/.github/workflows/ci.yaml | ||
[lc-shd]: https://img.shields.io/github/license/allyourcodebase/AFLplusplus.svg?style=for-the-badge&labelColor=black | ||
[lc-url]: https://github.com/allyourcodebase/AFLplusplus/blob/main/LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
const std = @import("std"); | ||
|
||
pub fn build(b: *std.Build) void { | ||
const target = b.standardTargetOptions(.{}); | ||
const optimize = b.standardOptimizeOption(.{}); | ||
const version = std.SemanticVersion{ .major = 4, .minor = 21, .patch = 0 }; | ||
|
||
// Dependencies | ||
const AFLplusplus_dep = b.dependency("AFLplusplus", .{}); | ||
const AFLplusplus_src_path = AFLplusplus_dep.path("src/"); | ||
const AFLplusplus_inc_path = AFLplusplus_dep.path("include/"); | ||
|
||
// Executable suite | ||
const exes_step = b.step("exes", "Install executables"); | ||
|
||
var flags = std.BoundedArray([]const u8, 15){}; | ||
flags.appendSliceAssumeCapacity(&FLAGS); | ||
if (target.result.cpu.arch.isX86()) { | ||
flags.appendSliceAssumeCapacity(&.{ "-mavx2", "-D_HAVE_AVX2" }); | ||
} | ||
if (target.query.isNative()) { | ||
flags.appendAssumeCapacity("-march=native"); | ||
} | ||
|
||
const fuzz_exe = b.addExecutable(.{ | ||
.name = "afl-fuzz", | ||
.pic = true, | ||
.target = target, | ||
.version = version, | ||
.optimize = optimize, | ||
}); | ||
fuzz_exe.addCSourceFiles(.{ | ||
.root = AFLplusplus_src_path, | ||
.files = &(FUZZ_SOURCES ++ SHARED_SOURCES), | ||
.flags = flags.constSlice(), | ||
}); | ||
fuzz_exe.addIncludePath(AFLplusplus_inc_path); | ||
fuzz_exe.linkSystemLibrary("z"); | ||
fuzz_exe.linkLibC(); | ||
|
||
const fuzz_exe_install = b.addInstallArtifact(fuzz_exe, .{}); | ||
exes_step.dependOn(&fuzz_exe_install.step); | ||
|
||
const showmap_exe = b.addExecutable(.{ | ||
.name = "afl-showmap", | ||
.pic = true, | ||
.target = target, | ||
.version = version, | ||
.optimize = optimize, | ||
}); | ||
showmap_exe.addCSourceFiles(.{ | ||
.root = AFLplusplus_src_path, | ||
.files = &(.{ "afl-showmap.c", "afl-fuzz-mutators.c", "afl-fuzz-python.c" } ++ SHARED_SOURCES), | ||
.flags = flags.constSlice(), | ||
}); | ||
showmap_exe.addIncludePath(AFLplusplus_inc_path); | ||
showmap_exe.linkSystemLibrary("z"); | ||
showmap_exe.linkLibC(); | ||
|
||
const showmap_exe_install = b.addInstallArtifact(showmap_exe, .{}); | ||
exes_step.dependOn(&showmap_exe_install.step); | ||
|
||
const tmin_exe = b.addExecutable(.{ | ||
.name = "afl-tmin", | ||
.pic = true, | ||
.target = target, | ||
.version = version, | ||
.optimize = optimize, | ||
}); | ||
tmin_exe.addCSourceFiles(.{ | ||
.root = AFLplusplus_src_path, | ||
.files = &(.{"afl-tmin.c"} ++ SHARED_SOURCES), | ||
.flags = flags.constSlice(), | ||
}); | ||
tmin_exe.addIncludePath(AFLplusplus_inc_path); | ||
tmin_exe.linkSystemLibrary("z"); | ||
tmin_exe.linkLibC(); | ||
|
||
const tmin_exe_install = b.addInstallArtifact(tmin_exe, .{}); | ||
exes_step.dependOn(&tmin_exe_install.step); | ||
|
||
const analyze_exe = b.addExecutable(.{ | ||
.name = "afl-analyze", | ||
.pic = true, | ||
.target = target, | ||
.version = version, | ||
.optimize = optimize, | ||
}); | ||
analyze_exe.addCSourceFiles(.{ | ||
.root = AFLplusplus_src_path, | ||
.files = &(.{"afl-analyze.c"} ++ SHARED_SOURCES), | ||
.flags = flags.constSlice(), | ||
}); | ||
analyze_exe.addIncludePath(AFLplusplus_inc_path); | ||
analyze_exe.linkSystemLibrary("z"); | ||
analyze_exe.linkLibC(); | ||
|
||
const analyze_exe_install = b.addInstallArtifact(analyze_exe, .{}); | ||
exes_step.dependOn(&analyze_exe_install.step); | ||
|
||
const gotcpu_exe = b.addExecutable(.{ | ||
.name = "afl-gotcpu", | ||
.pic = true, | ||
.target = target, | ||
.version = version, | ||
.optimize = optimize, | ||
}); | ||
gotcpu_exe.addCSourceFiles(.{ | ||
.root = AFLplusplus_src_path, | ||
.files = &.{ "afl-gotcpu.c", "afl-common.c" }, | ||
.flags = flags.constSlice(), | ||
}); | ||
gotcpu_exe.addIncludePath(AFLplusplus_inc_path); | ||
gotcpu_exe.linkSystemLibrary("z"); | ||
gotcpu_exe.linkLibC(); | ||
|
||
const gotcpu_exe_install = b.addInstallArtifact(gotcpu_exe, .{}); | ||
exes_step.dependOn(&gotcpu_exe_install.step); | ||
|
||
const as_exe = b.addExecutable(.{ | ||
.name = "afl-as", | ||
.pic = true, | ||
.target = target, | ||
.version = version, | ||
.optimize = optimize, | ||
}); | ||
as_exe.addCSourceFiles(.{ | ||
.root = AFLplusplus_src_path, | ||
.files = &.{"afl-as.c"}, | ||
.flags = flags.constSlice(), | ||
}); | ||
as_exe.addIncludePath(AFLplusplus_inc_path); | ||
as_exe.linkSystemLibrary("z"); | ||
as_exe.linkLibC(); | ||
|
||
const as_exe_install = b.addInstallArtifact(as_exe, .{}); | ||
exes_step.dependOn(&as_exe_install.step); | ||
|
||
b.default_step.dependOn(exes_step); | ||
|
||
// Formatting checks | ||
const fmt_step = b.step("fmt", "Run formatting checks"); | ||
|
||
const fmt = b.addFmt(.{ | ||
.paths = &.{ | ||
"build.zig", | ||
}, | ||
.check = true, | ||
}); | ||
fmt_step.dependOn(&fmt.step); | ||
b.default_step.dependOn(fmt_step); | ||
} | ||
|
||
const FUZZ_SOURCES = .{ | ||
"afl-fuzz-bitmap.c", | ||
"afl-fuzz-cmplog.c", | ||
"afl-fuzz-extras.c", | ||
"afl-fuzz-init.c", | ||
"afl-fuzz-mutators.c", | ||
"afl-fuzz-one.c", | ||
"afl-fuzz-python.c", | ||
"afl-fuzz-queue.c", | ||
"afl-fuzz-redqueen.c", | ||
"afl-fuzz-run.c", | ||
"afl-fuzz-skipdet.c", | ||
"afl-fuzz-state.c", | ||
"afl-fuzz-stats.c", | ||
"afl-fuzz-statsd.c", | ||
"afl-fuzz.c", | ||
}; | ||
|
||
const SHARED_SOURCES = .{ | ||
"afl-performance.c", | ||
"afl-common.c", | ||
"afl-forkserver.c", | ||
"afl-sharedmem.c", | ||
}; | ||
|
||
const FLAGS = .{ | ||
"-O2", | ||
"-g", | ||
"-Wno-pointer-sign", | ||
"-Wno-variadic-macros", | ||
"-Wall", | ||
"-Wextra", | ||
"-Wno-pointer-arith", | ||
"-D_AFL_SPECIAL_PERFORMANCE", | ||
"-DHAVE_ZLIB", | ||
"-DAFL_PATH=\"\"", | ||
"-DBIN_PATH=\"\"", | ||
"-DDOC_PATH=\"\"", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.{ | ||
.name = "AFLplusplus", | ||
.version = "4.21.0", | ||
.minimum_zig_version = "0.13.0", | ||
.dependencies = .{ | ||
.AFLplusplus = .{ | ||
.url = "https://github.com/AFLplusplus/AFLplusplus/archive/19ca7b3.tar.gz", | ||
.hash = "12202609f778b890810bfa3a2574c8319dc211e170419bc2bc4f51241f549ba5033a", | ||
}, | ||
}, | ||
.paths = .{ | ||
"build.zig", | ||
"build.zig.zon", | ||
"LICENSE", | ||
"README.md", | ||
}, | ||
} |