oss-fuzz/infra/base-images/base-builder/README.md

84 lines
2.9 KiB
Markdown
Raw Normal View History

# base-builder
2016-10-07 18:34:42 +00:00
> Abstract base image for libfuzzer builders.
2016-11-30 16:26:02 +00:00
Every project image supports multiple commands that can be invoked through docker after the image is built:
2016-11-22 20:02:26 +00:00
<pre>
docker run --rm -ti gcr.io/oss-fuzz/<b><i>$project</i></b> <i>&lt;command&gt;</i> <i>&lt;arguments...&gt;</i>
2016-11-22 20:02:26 +00:00
</pre>
2016-11-11 23:25:37 +00:00
# Supported Commands
2016-10-07 18:34:42 +00:00
| Command | Description |
|---------|-------------|
2016-11-30 16:26:02 +00:00
| `compile` (default) | build all fuzz targets
| `/bin/bash` | drop into shell, execute `compile` script to start build.
2016-10-07 18:34:42 +00:00
# Build Configuration
A single build image can build same set of fuzzers in many configurations.
The configuration is picked through one or more environment variables.
2016-12-22 18:48:28 +00:00
| Env Variable | Description
| ------------- | --------
2017-02-03 02:48:11 +00:00
| `$SANITIZER ("address")` | Specifies predefined sanitizer configuration to use. `address` or `memory` or `undefined`.
2016-12-05 17:44:57 +00:00
| `$SANITIZER_FLAGS` | Specify compiler sanitizer flags directly. Overrides `$SANITIZER`.
| `$COVERAGE_FLAGS` | Specify compiler flags to use for fuzzer feedback coverage.
| `$BUILD_UID` | User id to use while building fuzzers.
2016-12-22 18:48:28 +00:00
## Examples
- *building sqlite3 fuzzer with UBSan (`SANITIZER=undefined`):*
<pre>
docker run --rm -ti -e <i>SANITIZER</i>=<i>undefined</i> gcr.io/oss-fuzz/sqlite3
</pre>
2016-10-13 21:02:19 +00:00
# Image Files Layout
2016-12-02 19:02:18 +00:00
| Location|Env| Description |
2016-12-02 19:02:02 +00:00
|---------| -------- | ---------- |
| `/out/` | `$OUT` | Directory to store build artifacts (fuzz targets, dictionaries, options files, seed corpus archives). |
| `/src/` | `$SRC` | Directory to checkout source files |
| `/work/`| `$WORK` | Directory for storing intermediate files |
| `/usr/lib/libFuzzingEngine.a` | `$LIB_FUZZING_ENGINE` | Location of prebuilt fuzzing engine library (e.g. libFuzzer ) that needs to be linked with all fuzz targets (`-lFuzzingEngine`).
2016-10-13 21:02:19 +00:00
While files layout is fixed within a container, the environment variables are
provided to be able to write retargetable scripts.
## Compiler Flags
2016-10-13 21:02:19 +00:00
2016-11-30 16:26:02 +00:00
You *must* use special compiler flags to build your project and fuzz targets.
2016-10-13 21:02:19 +00:00
These flags are provided in following environment variables:
| Env Variable | Description
| ------------- | --------
| `$CC` | The C compiler binary.
| `$CXX`, `$CCC` | The C++ compiler binary.
| `$CFLAGS` | C compiler flags.
| `$CXXFLAGS` | C++ compiler flags.
2016-11-30 16:26:02 +00:00
Most well-crafted build scripts will automatically use these variables. If not,
pass them manually to the build tool.
2016-10-13 21:02:19 +00:00
2016-10-07 18:34:42 +00:00
# Child Image Interface
## Sources
2016-10-07 18:34:42 +00:00
2016-11-30 16:26:02 +00:00
Child image has to checkout all sources that it needs to compile fuzz targets into
2016-12-07 19:35:53 +00:00
`$SRC` directory. When the image is executed, a directory could be mounted on top
2016-11-30 16:26:02 +00:00
of these with local checkouts using
`docker run -v $HOME/my_project:/src/my_project ...`.
2016-10-07 18:34:42 +00:00
## Other Required Files
Following files have to be added by child images:
| File Location | Description |
| ------------- | ----------- |
2016-11-30 16:26:02 +00:00
| `$SRC/build.sh` | build script to build the project and its fuzz targets |