aboutsummaryrefslogtreecommitdiffhomepage
path: root/projects/nss/build.sh
blob: 6a35c478953f1ef77d0abc5b999d4deaa7138f86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash -eu
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################

# Build the library.
make CCC="$CXX" XCFLAGS="$CXXFLAGS" SANITIZER_CFLAGS="$CXXFLAGS" \
    BUILD_OPT=1 USE_64=1 NSS_DISABLE_GTESTS=1 ZDEFS_FLAG= \
    nss_clean_all nss_build_all
cd ..

# Copy libraries and some objects to $WORK/nss/lib.
mkdir -p $WORK/nss/lib
cp dist/Linux*/lib/*.a $WORK/nss/lib
cp nspr/Linux*/pr/src/misc/prlog2.o $WORK/nss/lib

# Copy includes to $WORK/nss/include.
mkdir -p $WORK/nss/include
cp -rL dist/Linux*/include/* $WORK/nss/include
cp -rL dist/{public,private}/nss/* $WORK/nss/include


# Build the fuzzers.
FUZZERS="asn1_algorithmid_fuzzer \
  asn1_any_fuzzer \
  asn1_bitstring_fuzzer \
  asn1_bmpstring_fuzzer \
  asn1_boolean_fuzzer \
  asn1_generalizedtime_fuzzer \
  asn1_ia5string_fuzzer \
  asn1_integer_fuzzer \
  asn1_null_fuzzer \
  asn1_objectid_fuzzer \
  asn1_octetstring_fuzzer \
  asn1_utctime_fuzzer \
  asn1_utf8string_fuzzer"

# The following fuzzers are currently disabled due to linking issues:
#  cert_certificate_fuzzer, seckey_privatekeyinfo_fuzzer


for fuzzer in $FUZZERS; do
  $CXX $CXXFLAGS -std=c++11 $SRC/$fuzzer.cc \
     -I$WORK/nss/include \
     -lFuzzingEngine \
     $WORK/nss/lib/libnss.a $WORK/nss/lib/libnssutil.a \
     $WORK/nss/lib/libnspr4.a $WORK/nss/lib/libplc4.a $WORK/nss/lib/libplds4.a \
     $WORK/nss/lib/prlog2.o -o $OUT/$fuzzer
done

# Archive and copy to $OUT seed corpus if the build succeeded.
zip $WORK/nss/all_nss_seed_corpus.zip $SRC/nss-corpus/*/*

for fuzzer in $FUZZERS; do
  cp $WORK/nss/all_nss_seed_corpus.zip $OUT/${fuzzer}_seed_corpus.zip
done