Fix: symbols/bionic/lib64/libc.so is the wrong variant
The new module type bionic_mountpoint wasn't mutated by the sanitizer.
As a result, it has been taking non-sanitized symbol libraries even for
sanitized builds. Fixing the issue by making the module type to
implement the cc.Sanitizeable interface so that it can be mutated by the
sanitizer.
Bug: 124469750
Test: SANITIZE_TARGET=hwaddress m
Inspect Android-<target>.mk and check that LOCAL_SOONG_UNSTRIPPED_BINARY
for libc.mountpoint module is pointing to a hwasan variant of libc.so
Change-Id: I10c863c0dbd361463648a4b7d897a4f88a9c85cb
diff --git a/build/bionic.go b/build/bionic.go
index 93c2494..54ad10b 100644
--- a/build/bionic.go
+++ b/build/bionic.go
@@ -89,6 +89,9 @@
// Symlinks to the mountpoints from the system and recovery partitions
// Symlinks names will have the same suffix as the mount point
Symlinks []string
+
+ // List of sanitizer names that this APEX is enabled for
+ SanitizerNames []string `blueprint:"mutated"`
}
type dependencyTag struct {
@@ -98,6 +101,31 @@
var mountsourceTag = dependencyTag{name: "mountsource"}
+
+func (m *bionicMountpoint) EnableSanitizer(sanitizerName string) {
+ if !android.InList(sanitizerName, m.properties.SanitizerNames) {
+ m.properties.SanitizerNames = append(m.properties.SanitizerNames, sanitizerName)
+ }
+}
+
+func (m *bionicMountpoint) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
+ if android.InList(sanitizerName, m.properties.SanitizerNames) {
+ return true
+ }
+
+ // Then follow the global setting
+ globalSanitizerNames := []string{}
+ if m.Host() {
+ globalSanitizerNames = ctx.Config().SanitizeHost()
+ } else {
+ arches := ctx.Config().SanitizeDeviceArch()
+ if len(arches) == 0 || android.InList(m.Arch().ArchType.Name, arches) {
+ globalSanitizerNames = ctx.Config().SanitizeDevice()
+ }
+ }
+ return android.InList(sanitizerName, globalSanitizerNames)
+}
+
func (m *bionicMountpoint) DepsMutator(ctx android.BottomUpMutatorContext) {
if Bool(m.properties.Library) == Bool(m.properties.Binary) {
ctx.ModuleErrorf("either binary or library must be set to true")