Allow sanitize attribute on cc_objects and propagate sanitize attributes into them.

Without this change, we can end up failing to sanitize parts of libraries
that are compiled as cc_objects, such as bcm_object.o in boringssl. This
is normally harmless (except that the sanitizer would fail to detect bugs
in unsanitized code), however boringssl in particular needs to be compiled
with HWASAN enabled in all translation units in order to avoid link errors
with newer toolchains that support HWASAN global instrumentation.

Change-Id: Ib8bd325f76b7852cab435bff79d6945768298a5c
This commit is contained in:
Peter Collingbourne
2019-09-26 12:24:45 -07:00
parent 84dfc3d331
commit 1c648b8936
2 changed files with 3 additions and 2 deletions

View File

@@ -52,8 +52,9 @@ type ObjectLinkerProperties struct {
// input to a cc_genrule module.
func ObjectFactory() android.Module {
module := newBaseModule(android.HostAndDeviceSupported, android.MultilibBoth)
module.sanitize = &sanitize{}
module.linker = &objectLinker{
baseLinker: NewBaseLinker(nil),
baseLinker: NewBaseLinker(module.sanitize),
}
module.compiler = NewBaseCompiler()

View File

@@ -674,7 +674,7 @@ func (sanitize *sanitize) isSanitizerEnabled(t sanitizerType) bool {
func isSanitizableDependencyTag(tag blueprint.DependencyTag) bool {
t, ok := tag.(dependencyTag)
return ok && t.library || t == reuseObjTag
return ok && t.library || t == reuseObjTag || t == objDepTag
}
// Propagate sanitizer requirements down from binaries