Add handling for libc_hwasan to Soong
libc_hwasan is a new library in the runtime apex that lives in
bionic/hwasan/libc.so and is symlinked to /system/lib64/hwasan/libc.so.
This is chosen by the linker if an app or binary requires HWASan
support.
Bug: 276930343
Change-Id: If331744ad84241ad99a41805ea3110d37cf9b0af
diff --git a/cc/library.go b/cc/library.go
index 7504302..172ca64 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -2193,7 +2193,16 @@
func (library *libraryDecorator) installSymlinkToRuntimeApex(ctx ModuleContext, file android.Path) {
dir := library.baseInstaller.installDir(ctx)
dirOnDevice := android.InstallPathToOnDevicePath(ctx, dir)
- target := "/" + filepath.Join("apex", "com.android.runtime", dir.Base(), "bionic", file.Base())
+ // libc_hwasan has relative_install_dir set, which would mess up the dir.Base() logic.
+ // hardcode here because it's the only target, if we have other targets that use this
+ // we can generalise this.
+ var target string
+ if ctx.baseModuleName() == "libc_hwasan" {
+ target = "/" + filepath.Join("apex", "com.android.runtime", "lib64", "bionic", "hwasan", file.Base())
+ } else {
+ base := dir.Base()
+ target = "/" + filepath.Join("apex", "com.android.runtime", base, "bionic", file.Base())
+ }
ctx.InstallAbsoluteSymlink(dir, file.Base(), target)
library.postInstallCmds = append(library.postInstallCmds, makeSymlinkCmd(dirOnDevice, file.Base(), target))
}