Add libc_malloc_debug and _hooks to the runtime APEX

The two libraries share implementation details with libc.so, therefore
they should be bundled in the runtime APEX together with libc.so

Bug: 122566199
Test: m
Test: /art/tools/dist_linux_bionic.sh -j50 com.android.runtime.host

Change-Id: I2ee0b93855144bcc509c61b7db956c64528921f9
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index bfa4043..d2bc678 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -48,6 +48,14 @@
     "libm",
     "libdl",
 ]
+
+bionic_native_shared_libs_device = [
+    // ... and their internal dependencies
+    // These are available only on device
+    "libc_malloc_debug",
+    "libc_malloc_hooks",
+]
+
 bionic_binaries_both = [
     "linker",
 ]
@@ -229,6 +237,7 @@
 apex {
     name: "com.android.runtime.release",
     defaults: ["com.android.runtime-defaults"],
+    native_shared_libs: bionic_native_shared_libs_device,
     certificate: ":com.android.runtime.release.certificate",
 }
 
@@ -239,7 +248,8 @@
     name: "com.android.runtime.debug",
     defaults: ["com.android.runtime-defaults"],
     native_shared_libs: art_runtime_debug_native_shared_libs
-        + libcore_debug_native_shared_libs,
+        + libcore_debug_native_shared_libs
+        + bionic_native_shared_libs_device,
     multilib: {
         prefer32: {
             binaries: art_runtime_debug_binaries_prefer32
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index a1fe713..434edc7 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -484,6 +484,9 @@
     self._checker.check_native_library('bionic/libc')
     self._checker.check_native_library('bionic/libdl')
     self._checker.check_native_library('bionic/libm')
+    # ... and its internal dependencies
+    self._checker.check_native_library('libc_malloc_hooks')
+    self._checker.check_native_library('libc_malloc_debug')
 
     # Check exported native libraries for Managed Core Library.
     self._checker.check_native_library('libandroidicu')