Teach soong not to duplicate the HWASAN runtime into each APEX.
When HWASAN is enabled, the runtime is conceptually part of Bionic (and
mutually depends on it), so it needs to be treated in the same way as the
Bionic libs.
Now there are only two copies of the runtime: the one in
/system/lib64/bootstrap (which won't be used by ordinary processes) and the
one in the runtime APEX.
This reduces the size of the HWASAN system image and fixes an issue where
multiple copies of the HWASAN runtime were being loaded into 64-bit binaries in
APEXes because the linker namespace for the binary is different from the one
for its dependent libraries outside of APEXes. HWASAN only supports loading
one copy of the runtime per process, so this was causing such binaries to
crash on startup.
Change-Id: I228896e193a035e6dfba9f6e28d0b2e12fc163ea
diff --git a/apex/apex.go b/apex/apex.go
index 68d0bc1..51d0718 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -521,6 +521,17 @@
a.properties.Multilib.Prefer32.Binaries, target.String(),
a.getImageVariation(config))
}
+
+ if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device {
+ for _, sanitizer := range ctx.Config().SanitizeDevice() {
+ if sanitizer == "hwaddress" {
+ addDependenciesForNativeModules(ctx,
+ []string{"libclang_rt.hwasan-aarch64-android"},
+ nil, target.String(), a.getImageVariation(config))
+ break
+ }
+ }
+ }
}
}