• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2019 Google Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16################################################################################
17
18# Case-sensitive names of internal Firefox fuzzing targets. Edit to add more.
19FUZZ_TARGETS=(
20  StructuredCloneReader
21  Wasm
22)
23
24# Install dependencies. Note that bootstrap installs cargo, which must be added
25# to PATH via source. In a successive run (for a different sanitizer), the
26# cargo installation carries over, but bootstrap fails if cargo is not in PATH.
27export SHELL=/bin/bash
28[[ -f "$HOME/.cargo/env" ]] && source $HOME/.cargo/env
29../../mach bootstrap --no-interactive --application-choice browser
30source $HOME/.cargo/env
31
32autoconf2.13
33
34# Update internal libFuzzer.
35(cd ../../tools/fuzzing/libfuzzer && ./clone_libfuzzer.sh HEAD)
36
37mkdir -p build_OPT.OBJ
38cd build_OPT.OBJ
39
40../configure \
41    --enable-optimize \
42    --disable-shared-js \
43    --disable-jemalloc \
44    --enable-tests \
45    --enable-fuzzing \
46    --enable-$SANITIZER-sanitizer
47
48make "-j$(nproc)"
49
50cp dist/bin/fuzz-tests $OUT
51
52# Build a wrapper binary for each target to set environment variables.
53for FUZZ_TARGET in ${FUZZ_TARGETS[@]}
54do
55  $CC $CFLAGS -O0 \
56    -DFUZZ_TARGET=$FUZZ_TARGET \
57    $SRC/target.c -o $OUT/$FUZZ_TARGET
58done
59
60# Copy libraries.
61mkdir -p $OUT/lib
62cp -L /usr/lib/x86_64-linux-gnu/libc++.so.1 $OUT/lib
63cp -L /usr/lib/x86_64-linux-gnu/libc++abi.so.1 $OUT/lib
64
65