• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 Code Intelligence GmbH
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.code_intelligence.jazzer.runtime;
16 
17 import com.github.fmeum.rules_jni.RulesJni;
18 
19 /**
20  * The native functions used by FuzzTargetRunner.
21  *
22  * <p>This class has to be loaded by the bootstrap class loader since the native library it loads
23  * links in libFuzzer and the Java hooks, which have to be on the bootstrap path so that they are
24  * seen by Java standard library classes, need to be able to call native libFuzzer callbacks.
25  */
26 public class FuzzTargetRunnerNatives {
27   static {
28     if (!Constants.IS_ANDROID && FuzzTargetRunnerNatives.class.getClassLoader() != null) {
29       throw new IllegalStateException(
30           "FuzzTargetRunnerNatives must be loaded in the bootstrap loader");
31     }
32     RulesJni.loadLibrary("jazzer_driver", "/com/code_intelligence/jazzer/driver");
33   }
34 
startLibFuzzer( byte[][] args, Class<?> runner, boolean useExperimentalMutator)35   public static native int startLibFuzzer(
36       byte[][] args, Class<?> runner, boolean useExperimentalMutator);
37 
printCrashingInput()38   public static native void printCrashingInput();
39 
temporarilyDisableLibfuzzerExitHook()40   public static native void temporarilyDisableLibfuzzerExitHook();
41 }
42