Merge "Revert "Updated the way we build AFL++ fuzz binaries""
This commit is contained in:
@@ -27,21 +27,13 @@ import (
|
||||
"android/soong/android"
|
||||
)
|
||||
|
||||
type Lang string
|
||||
type FuzzType string
|
||||
|
||||
const (
|
||||
Cc Lang = "cc"
|
||||
Rust Lang = "rust"
|
||||
Java Lang = "java"
|
||||
)
|
||||
|
||||
type Framework string
|
||||
|
||||
const (
|
||||
AFL Framework = "afl"
|
||||
LibFuzzer Framework = "libfuzzer"
|
||||
Jazzer Framework = "jazzer"
|
||||
UnknownFramework Framework = "unknownframework"
|
||||
Cc FuzzType = ""
|
||||
Rust FuzzType = "rust"
|
||||
Java FuzzType = "java"
|
||||
AFL FuzzType = "AFL"
|
||||
)
|
||||
|
||||
var BoolDefault = proptools.BoolDefault
|
||||
@@ -56,6 +48,7 @@ type FuzzPackager struct {
|
||||
Packages android.Paths
|
||||
FuzzTargets map[string]bool
|
||||
SharedLibInstallStrings []string
|
||||
FuzzType FuzzType
|
||||
}
|
||||
|
||||
type FileToZip struct {
|
||||
@@ -153,12 +146,6 @@ type FuzzConfig struct {
|
||||
IsJni *bool `json:"is_jni,omitempty"`
|
||||
}
|
||||
|
||||
type FuzzFrameworks struct {
|
||||
Afl *bool
|
||||
Libfuzzer *bool
|
||||
Jazzer *bool
|
||||
}
|
||||
|
||||
type FuzzProperties struct {
|
||||
// Optional list of seed files to be installed to the fuzz target's output
|
||||
// directory.
|
||||
@@ -168,10 +155,6 @@ type FuzzProperties struct {
|
||||
Data []string `android:"path"`
|
||||
// Optional dictionary to be installed to the fuzz target's output directory.
|
||||
Dictionary *string `android:"path"`
|
||||
// Define the fuzzing frameworks this fuzz target can be built for. If
|
||||
// empty then the fuzz target will be available to be built for all fuzz
|
||||
// frameworks available
|
||||
Fuzzing_frameworks *FuzzFrameworks
|
||||
// Config for running the target on fuzzing infrastructure.
|
||||
Fuzz_config *FuzzConfig
|
||||
}
|
||||
@@ -186,49 +169,6 @@ type FuzzPackagedModule struct {
|
||||
DataIntermediateDir android.Path
|
||||
}
|
||||
|
||||
func GetFramework(ctx android.LoadHookContext, lang Lang) Framework {
|
||||
framework := ctx.Config().Getenv("FUZZ_FRAMEWORK")
|
||||
|
||||
if lang == Cc {
|
||||
switch strings.ToLower(framework) {
|
||||
case "":
|
||||
return LibFuzzer
|
||||
case "libfuzzer":
|
||||
return LibFuzzer
|
||||
case "afl":
|
||||
return AFL
|
||||
}
|
||||
} else if lang == Rust {
|
||||
return LibFuzzer
|
||||
} else if lang == Java {
|
||||
return Jazzer
|
||||
}
|
||||
|
||||
ctx.ModuleErrorf(fmt.Sprintf("%s is not a valid fuzzing framework for %s", framework, lang))
|
||||
return UnknownFramework
|
||||
}
|
||||
|
||||
func IsValidFrameworkForModule(targetFramework Framework, lang Lang, moduleFrameworks *FuzzFrameworks) bool {
|
||||
if targetFramework == UnknownFramework {
|
||||
return false
|
||||
}
|
||||
|
||||
if moduleFrameworks == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
switch targetFramework {
|
||||
case LibFuzzer:
|
||||
return proptools.BoolDefault(moduleFrameworks.Libfuzzer, true)
|
||||
case AFL:
|
||||
return proptools.BoolDefault(moduleFrameworks.Afl, true)
|
||||
case Jazzer:
|
||||
return proptools.BoolDefault(moduleFrameworks.Jazzer, true)
|
||||
default:
|
||||
panic("%s is not supported as a fuzz framework")
|
||||
}
|
||||
}
|
||||
|
||||
func IsValid(fuzzModule FuzzModule) bool {
|
||||
// Discard ramdisk + vendor_ramdisk + recovery modules, they're duplicates of
|
||||
// fuzz targets we're going to package anyway.
|
||||
@@ -327,7 +267,7 @@ func (f *FuzzConfig) String() string {
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func (s *FuzzPackager) CreateFuzzPackage(ctx android.SingletonContext, archDirs map[ArchOs][]FileToZip, fuzzType Lang, pctx android.PackageContext) {
|
||||
func (s *FuzzPackager) CreateFuzzPackage(ctx android.SingletonContext, archDirs map[ArchOs][]FileToZip, fuzzType FuzzType, pctx android.PackageContext) {
|
||||
var archOsList []ArchOs
|
||||
for archOs := range archDirs {
|
||||
archOsList = append(archOsList, archOs)
|
||||
@@ -346,7 +286,9 @@ func (s *FuzzPackager) CreateFuzzPackage(ctx android.SingletonContext, archDirs
|
||||
if fuzzType == Java {
|
||||
zipFileName = "fuzz-java-" + hostOrTarget + "-" + arch + ".zip"
|
||||
}
|
||||
|
||||
if fuzzType == AFL {
|
||||
zipFileName = "fuzz-afl-" + hostOrTarget + "-" + arch + ".zip"
|
||||
}
|
||||
outputFile := android.PathForOutput(ctx, zipFileName)
|
||||
|
||||
s.Packages = append(s.Packages, outputFile)
|
||||
|
Reference in New Issue
Block a user