• 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.
25export SHELL=/bin/bash
26../../mach --no-interactive bootstrap --application-choice browser
27
28autoconf2.13
29
30# Skip patches for now
31rm ../../tools/fuzzing/libfuzzer/patches/*.patch
32touch ../../tools/fuzzing/libfuzzer/patches/dummy.patch
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-debug \
42    --enable-optimize="-O2 -gline-tables-only" \
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