rust: Package shared libraries with fuzzer zips
Rust fuzzers were not packaging up their CC shared dependencies. This would lead to fuzzers using the shared libraries included on system, which may not be sanitized, leading to incorrect behavior. This refactors the relevant code from CC and calls it from the Rust build logic. Bug: 202282599 Test: output rust fuzzer zip file includes shared dependencies. Change-Id: I92196eb0141733797a67eae24f8e9aedea94c3bc
This commit is contained in:
10
rust/fuzz.go
10
rust/fuzz.go
@@ -111,6 +111,10 @@ func (s *rustFuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
// List of individual fuzz targets.
|
||||
s.FuzzTargets = make(map[string]bool)
|
||||
|
||||
// Map tracking whether each shared library has an install rule to avoid duplicate install rules from
|
||||
// multiple fuzzers that depend on the same shared library.
|
||||
sharedLibraryInstalled := make(map[string]bool)
|
||||
|
||||
ctx.VisitAllModules(func(module android.Module) {
|
||||
// Discard non-fuzz targets.
|
||||
rustModule, ok := module.(*Module)
|
||||
@@ -145,6 +149,12 @@ func (s *rustFuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
// The executable.
|
||||
files = append(files, fuzz.FileToZip{rustModule.unstrippedOutputFile.Path(), ""})
|
||||
|
||||
// Grab the list of required shared libraries.
|
||||
sharedLibraries := fuzz.CollectAllSharedDependencies(ctx, module, cc.UnstrippedOutputFile, cc.IsValidSharedDependency)
|
||||
|
||||
// Package shared libraries
|
||||
files = append(files, cc.GetSharedLibsToZip(sharedLibraries, rustModule, &s.FuzzPackager, archString, &sharedLibraryInstalled)...)
|
||||
|
||||
archDirs[archOs], ok = s.BuildZipFile(ctx, module, fuzzModule.fuzzPackagedModule, files, builder, archDir, archString, hostOrTargetString, archOs, archDirs)
|
||||
if !ok {
|
||||
return
|
||||
|
@@ -594,6 +594,13 @@ func (mod *Module) CcLibraryInterface() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (mod *Module) UnstrippedOutputFile() android.Path {
|
||||
if mod.unstrippedOutputFile.Valid() {
|
||||
return mod.unstrippedOutputFile.Path()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mod *Module) IncludeDirs() android.Paths {
|
||||
if mod.compiler != nil {
|
||||
if library, ok := mod.compiler.(*libraryDecorator); ok {
|
||||
|
Reference in New Issue
Block a user