Support asan/hwasan versions of prebuilts.
In apex_set and cc_prebuilt_library_*, provide a way to specify an alternative source to use when build with sanitizers. Test: prebuilt_test, apex_test Change-Id: I1ab8091bf696d94da3547cf5248853df489bdee6
This commit is contained in:
@@ -38,10 +38,11 @@ type prebuiltLinkerInterface interface {
|
||||
}
|
||||
|
||||
type prebuiltLinkerProperties struct {
|
||||
|
||||
// a prebuilt library or binary. Can reference a genrule module that generates an executable file.
|
||||
Srcs []string `android:"path,arch_variant"`
|
||||
|
||||
Sanitized Sanitized `android:"arch_variant"`
|
||||
|
||||
// Check the prebuilt ELF files (e.g. DT_SONAME, DT_NEEDED, resolution of undefined
|
||||
// symbols, etc), default true.
|
||||
Check_elf_files *bool
|
||||
@@ -105,7 +106,7 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext,
|
||||
p.libraryDecorator.addExportedGeneratedHeaders(deps.ReexportedGeneratedHeaders...)
|
||||
|
||||
// TODO(ccross): verify shared library dependencies
|
||||
srcs := p.prebuiltSrcs()
|
||||
srcs := p.prebuiltSrcs(ctx)
|
||||
if len(srcs) > 0 {
|
||||
builderFlags := flagsToBuilderFlags(flags)
|
||||
|
||||
@@ -177,15 +178,18 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *prebuiltLibraryLinker) prebuiltSrcs() []string {
|
||||
func (p *prebuiltLibraryLinker) prebuiltSrcs(ctx android.BaseModuleContext) []string {
|
||||
sanitize := ctx.Module().(*Module).sanitize
|
||||
srcs := p.properties.Srcs
|
||||
srcs = append(srcs, srcsForSanitizer(sanitize, p.properties.Sanitized)...)
|
||||
if p.static() {
|
||||
srcs = append(srcs, p.libraryDecorator.StaticProperties.Static.Srcs...)
|
||||
srcs = append(srcs, srcsForSanitizer(sanitize, p.libraryDecorator.StaticProperties.Static.Sanitized)...)
|
||||
}
|
||||
if p.shared() {
|
||||
srcs = append(srcs, p.libraryDecorator.SharedProperties.Shared.Srcs...)
|
||||
srcs = append(srcs, srcsForSanitizer(sanitize, p.libraryDecorator.SharedProperties.Shared.Sanitized)...)
|
||||
}
|
||||
|
||||
return srcs
|
||||
}
|
||||
|
||||
@@ -212,8 +216,8 @@ func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDec
|
||||
|
||||
module.AddProperties(&prebuilt.properties)
|
||||
|
||||
srcsSupplier := func() []string {
|
||||
return prebuilt.prebuiltSrcs()
|
||||
srcsSupplier := func(ctx android.BaseModuleContext) []string {
|
||||
return prebuilt.prebuiltSrcs(ctx)
|
||||
}
|
||||
|
||||
android.InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, "srcs")
|
||||
@@ -425,3 +429,28 @@ func NewPrebuiltBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecor
|
||||
android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
|
||||
return module, binary
|
||||
}
|
||||
|
||||
type Sanitized struct {
|
||||
None struct {
|
||||
Srcs []string `android:"path,arch_variant"`
|
||||
} `android:"arch_variant"`
|
||||
Address struct {
|
||||
Srcs []string `android:"path,arch_variant"`
|
||||
} `android:"arch_variant"`
|
||||
Hwaddress struct {
|
||||
Srcs []string `android:"path,arch_variant"`
|
||||
} `android:"arch_variant"`
|
||||
}
|
||||
|
||||
func srcsForSanitizer(sanitize *sanitize, sanitized Sanitized) []string {
|
||||
if sanitize == nil {
|
||||
return nil
|
||||
}
|
||||
if Bool(sanitize.Properties.Sanitize.Address) && sanitized.Address.Srcs != nil {
|
||||
return sanitized.Address.Srcs
|
||||
}
|
||||
if Bool(sanitize.Properties.Sanitize.Hwaddress) && sanitized.Hwaddress.Srcs != nil {
|
||||
return sanitized.Hwaddress.Srcs
|
||||
}
|
||||
return sanitized.None.Srcs
|
||||
}
|
||||
|
Reference in New Issue
Block a user