From 4c6ea0c88778c96472c81e73b0f47834f01f55fe Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Mon, 1 Jul 2019 07:16:17 -0700 Subject: [PATCH] [sledge] Use standard "libFuzzer" name Summary: Trivial renamings to use the standard "libFuzzer" name instead of "lib fuzzer". Reviewed By: kren1 Differential Revision: D16067881 fbshipit-source-id: 3ff2a8f86 --- sledge/sledge-help.txt | 8 ++++---- sledge/src/llair/frontend.ml | 6 +++--- sledge/src/llair/frontend.mli | 2 +- sledge/src/sledge.ml | 6 +++--- sledge/src/sledge_buck.ml | 13 ++++++------- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/sledge/sledge-help.txt b/sledge/sledge-help.txt index ce6d972d4..8534e0b5e 100644 --- a/sledge/sledge-help.txt +++ b/sledge/sledge-help.txt @@ -47,7 +47,7 @@ Analyze code in a buck target. This is a convenience wrapper for the sequence `s [-bound ] stop execution exploration at depth [-function-summaries] use function summaries (in development) - [-lib-fuzzer] add a harness for lib fuzzer binaries + [-fuzzer] add a harness for libFuzzer targets [-llair-output ] write generated LLAIR to [-modules ] write list of bitcode files to , or to standard output if is `-` @@ -85,7 +85,7 @@ Link code in a buck target to a single LLVM bitcode module. This also internaliz === flags === -bitcode-output write linked bitcode to - [-lib-fuzzer] add a harness for lib fuzzer binaries + [-fuzzer] add a harness for libFuzzer targets [-modules ] write list of bitcode files to , or to standard output if is `-` [-trace ] enable debug tracing @@ -120,7 +120,7 @@ Analyze code in one or more LLVM bitcode files. This is a convenience wrapper fo [-bound ] stop execution exploration at depth [-function-summaries] use function summaries (in development) - [-lib-fuzzer] add a harness for lib fuzzer binaries + [-fuzzer] add a harness for libFuzzer targets [-llair-output ] write generated LLAIR to [-skip-throw] do not explore past throwing an exception [-trace ] enable debug tracing @@ -138,7 +138,7 @@ Translate one or more LLVM bitcode files to LLAIR. Each filename may be === flags === - [-lib-fuzzer] add a harness for lib fuzzer binaries + [-fuzzer] add a harness for libFuzzer targets [-llair-output ] write generated LLAIR to [-trace ] enable debug tracing [-help] print this help text and exit diff --git a/sledge/src/llair/frontend.ml b/sledge/src/llair/frontend.ml index ae74c27bd..1547b248c 100644 --- a/sledge/src/llair/frontend.ml +++ b/sledge/src/llair/frontend.ml @@ -1395,8 +1395,8 @@ let link_in : Llvm.llcontext -> Llvm.lllinker -> string -> unit = |> [%Trace.retn fun {pf} _ -> pf ""] -let translate : lib_fuzzer_harness:bool -> string list -> Llair.t = - fun ~lib_fuzzer_harness inputs -> +let translate ~fuzzer : string list -> Llair.t = + fun inputs -> [%Trace.call fun {pf} -> pf "%a" (List.pp "@ " Format.pp_print_string) inputs] ; @@ -1409,7 +1409,7 @@ let translate : lib_fuzzer_harness:bool -> string list -> Llair.t = in Llvm_irreader.parse_ir llcontext model_memorybuffer in - ( if lib_fuzzer_harness then + ( if fuzzer then let lib_fuzzer_memorybuffer = Llvm.MemoryBuffer.of_string (Option.value_exn (Model.read "/lib_fuzzer_main.bc")) diff --git a/sledge/src/llair/frontend.mli b/sledge/src/llair/frontend.mli index ce3fbb63f..89cc9f150 100644 --- a/sledge/src/llair/frontend.mli +++ b/sledge/src/llair/frontend.mli @@ -9,6 +9,6 @@ exception Invalid_llvm of string -val translate : lib_fuzzer_harness:bool -> string list -> Llair.t +val translate : fuzzer:bool -> string list -> Llair.t (** Translate the compilation units in the named (llvm or bitcode) files to LLAIR. Attempts to raise [Invalid_llvm] when the input is invalid LLVM. *) diff --git a/sledge/src/sledge.ml b/sledge/src/sledge.ml index 1ea941ab4..ef6e33c12 100644 --- a/sledge/src/sledge.ml +++ b/sledge/src/sledge.ml @@ -88,11 +88,11 @@ let translate = let%map_open llair_output = flag "llair-output" (optional string) ~doc:" write generated LLAIR to " - and lib_fuzzer_harness = - flag "lib-fuzzer" no_arg ~doc:"add a harness for lib fuzzer binaries" + and fuzzer = + flag "fuzzer" no_arg ~doc:"add a harness for libFuzzer targets" in fun bitcode_inputs () -> - let program = Frontend.translate ~lib_fuzzer_harness bitcode_inputs in + let program = Frontend.translate ~fuzzer bitcode_inputs in Option.iter ~f:(marshal program) llair_output ; program diff --git a/sledge/src/sledge_buck.ml b/sledge/src/sledge_buck.ml index 2952b487b..625dec6c8 100644 --- a/sledge/src/sledge_buck.ml +++ b/sledge/src/sledge_buck.ml @@ -141,12 +141,12 @@ let bitcode_files_of ~target = List.map ~f:(make_absolute (Lazy.force buck_root)) modules (* link and optimize the modules *) -let llvm_link_opt ~lib_fuzzer_harness ~bitcode_output modules = +let llvm_link_opt ~fuzzer ~bitcode_output modules = let context = context () in - let modules = if lib_fuzzer_harness then "-" :: modules else modules in + let modules = if fuzzer then "-" :: modules else modules in let open Process in eval ~context - ( ( if lib_fuzzer_harness then + ( ( if fuzzer then echo ~n:() (Option.value_exn (Model.read "/lib_fuzzer_main.bc")) else return () ) |- run @@ -219,11 +219,10 @@ let main ~(command : unit Command.basic_command) ~analyze = let%map_open bitcode_output = flag "bitcode-output" (required abs_path_arg) ~doc:" write linked bitcode to " - and lib_fuzzer_harness = - flag "lib-fuzzer" no_arg - ~doc:"add a harness for lib fuzzer binaries" + and fuzzer = + flag "fuzzer" no_arg ~doc:"add a harness for libFuzzer targets" in - fun () -> llvm_link_opt ~lib_fuzzer_harness ~bitcode_output + fun () -> llvm_link_opt ~fuzzer ~bitcode_output in let param = bitcode_inputs |**> link in command ~summary ~readme param