summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Muhammad Haseeb Ahmad <mhahmad@google.com> 2022-10-20 00:55:58 +0000
committer Muhammad Haseeb Ahmad <mhahmad@google.com> 2022-10-20 00:55:58 +0000
commit431ddf9b7647a88bf36b004d94bfaff940c1f92b (patch)
treea75f14f8c0578e6a863aee7e9c4b67d10591b829
parent17b87958140076a5cd9c78969796772e7aa6bf1f (diff)
Output shared dependendencies of JNI libs for Java fuzzers
Test: m example_java_jni_fuzzer Bug: 252846698 Change-Id: Ib583de335482350bfe293f9c3d021a595edd4f44
-rw-r--r--cc/fuzz.go9
-rw-r--r--java/fuzz.go6
-rw-r--r--rust/fuzz.go2
3 files changed, 11 insertions, 6 deletions
diff --git a/cc/fuzz.go b/cc/fuzz.go
index 13c94adb3..0fbe45c8e 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -264,7 +264,7 @@ func (fuzzBin *fuzzBinary) install(ctx ModuleContext, file android.Path) {
}
// Grab the list of required shared libraries.
- fuzzBin.sharedLibraries = CollectAllSharedDependencies(ctx)
+ fuzzBin.sharedLibraries, _ = CollectAllSharedDependencies(ctx)
for _, lib := range fuzzBin.sharedLibraries {
fuzzBin.installedSharedDeps = append(fuzzBin.installedSharedDeps,
@@ -478,9 +478,10 @@ func GetSharedLibsToZip(sharedLibraries android.Paths, module LinkableInterface,
// VisitDirectDeps is used first to avoid incorrectly using the core libraries (sanitizer
// runtimes, libc, libdl, etc.) from a dependency. This may cause issues when dependencies
// have explicit sanitizer tags, as we may get a dependency on an unsanitized libc, etc.
-func CollectAllSharedDependencies(ctx android.ModuleContext) android.Paths {
+func CollectAllSharedDependencies(ctx android.ModuleContext) (android.Paths, []android.Module) {
seen := make(map[string]bool)
recursed := make(map[string]bool)
+ deps := []android.Module{}
var sharedLibraries android.Paths
@@ -494,6 +495,7 @@ func CollectAllSharedDependencies(ctx android.ModuleContext) android.Paths {
return
}
seen[ctx.OtherModuleName(dep)] = true
+ deps = append(deps, dep)
sharedLibraries = append(sharedLibraries, android.OutputFileForModule(ctx, dep, "unstripped"))
})
@@ -503,6 +505,7 @@ func CollectAllSharedDependencies(ctx android.ModuleContext) android.Paths {
}
if !seen[ctx.OtherModuleName(child)] {
seen[ctx.OtherModuleName(child)] = true
+ deps = append(deps, child)
sharedLibraries = append(sharedLibraries, android.OutputFileForModule(ctx, child, "unstripped"))
}
@@ -513,5 +516,5 @@ func CollectAllSharedDependencies(ctx android.ModuleContext) android.Paths {
return true
})
- return sharedLibraries
+ return sharedLibraries, deps
}
diff --git a/java/fuzz.go b/java/fuzz.go
index 848d364f1..1d6b91346 100644
--- a/java/fuzz.go
+++ b/java/fuzz.go
@@ -104,7 +104,9 @@ func (j *JavaFuzzLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
j.fuzzPackagedModule.Config = configPath
}
- ctx.VisitDirectDepsWithTag(cc.JniFuzzLibTag, func(dep android.Module) {
+ _, sharedDeps := cc.CollectAllSharedDependencies(ctx)
+
+ for _, dep := range sharedDeps {
sharedLibInfo := ctx.OtherModuleProvider(dep, cc.SharedLibraryInfoProvider).(cc.SharedLibraryInfo)
if sharedLibInfo.SharedLibrary != nil {
// The .class jars are output in slightly different locations
@@ -127,7 +129,7 @@ func (j *JavaFuzzLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
} else {
ctx.PropertyErrorf("jni_libs", "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep))
}
- })
+ }
j.Library.GenerateAndroidBuildActions(ctx)
}
diff --git a/rust/fuzz.go b/rust/fuzz.go
index 76cf21aa0..6faf55cf6 100644
--- a/rust/fuzz.go
+++ b/rust/fuzz.go
@@ -91,7 +91,7 @@ func (fuzzer *fuzzDecorator) compile(ctx ModuleContext, flags Flags, deps PathDe
out := fuzzer.binaryDecorator.compile(ctx, flags, deps)
// Grab the list of required shared libraries.
- fuzzer.sharedLibraries = cc.CollectAllSharedDependencies(ctx)
+ fuzzer.sharedLibraries, _ = cc.CollectAllSharedDependencies(ctx)
return out
}