oss-fuzz/infra/base-images/base-builder
jonathanmetzman 3976a002af
[i386] Improve linking and bad build check (#2410)
Improve linking by copying i386 libs instead of adding `-L` to `CXXFLAGS`
Get bad_build_check working for i386 binaries and add architecture check.
2019-05-14 10:18:02 -07:00
..
Dockerfile Add initial support for i386 builds (#2347) 2019-05-13 15:01:25 -07:00
README.md [infra] Fix broken markup in documentation files. 2017-12-22 09:09:40 -08:00
compile [i386] Improve linking and bad build check (#2410) 2019-05-14 10:18:02 -07:00
compile_afl Fix build breakage caused by unnecessary AFL testing (#2291) 2019-04-04 07:11:40 -07:00
compile_dataflow [infra] Enabling DataFlow build configuration (#1632). (#2292) 2019-04-09 07:25:14 -07:00
compile_honggfuzz Use standard clang/clang++ to build binaries to-be-fuzzed (#1031) 2017-12-09 15:08:04 -08:00
compile_libfuzzer Change LIB_FUZZING_ENGINE to -fsanitize=fuzzer in libFuzzer builds (#2312) 2019-04-15 10:05:02 -07:00
srcmap [infra] Enable debugging mode for srcmap script to make its failures more obvious. 2018-12-10 10:11:40 -08:00
write_labels.py Add support for tags field in project.yaml (#1974) (#1980) 2018-11-27 16:46:26 +11:00

README.md

base-builder

Abstract base image for libfuzzer builders.

Every project image supports multiple commands that can be invoked through docker after the image is built:

docker run --rm -ti gcr.io/oss-fuzz/$project <command> <arguments...>

Supported Commands

Command Description
compile (default) build all fuzz targets
/bin/bash drop into shell, execute compile script to start build.

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.

Env Variable Description
$SANITIZER ("address") Specifies predefined sanitizer configuration to use. address or memory or undefined.
$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.

Examples

  • building sqlite3 fuzzer with UBSan (SANITIZER=undefined):
docker run --rm -ti -e SANITIZER=undefined gcr.io/oss-fuzz/sqlite3

Image Files Layout

Location Env Description
/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).

While files layout is fixed within a container, the environment variables are provided to be able to write retargetable scripts.

Compiler Flags

You must use special compiler flags to build your project and fuzz targets. 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.

Most well-crafted build scripts will automatically use these variables. If not, pass them manually to the build tool.

Child Image Interface

Sources

Child image has to checkout all sources that it needs to compile fuzz targets into $SRC directory. When the image is executed, a directory could be mounted on top of these with local checkouts using docker run -v $HOME/my_project:/src/my_project ....

Other Required Files

Following files have to be added by child images:

File Location Description
$SRC/build.sh build script to build the project and its fuzz targets