Use version script for heapprofd client API.

This gets rid of some unnecessary symbols in the ELF, see
https://gist.github.com/fmayer/710baea398f014a229629eea25cd5b64

Test: perfetto_integrationtests

Bug: 160400319
Change-Id: I5b161aa9739c4b85f26b2f8e9ccfd7aad2633b2e
diff --git a/Android.bp b/Android.bp
index be1e483..efbc521 100644
--- a/Android.bp
+++ b/Android.bp
@@ -282,6 +282,7 @@
   header_libs: [
     "bionic_libc_platform_headers",
   ],
+  version_script: "src/profiling/memory/heapprofd_client_api.map.txt",
 }
 
 // GN: //src/ipc/protoc_plugin:ipc_plugin
diff --git a/src/profiling/memory/heapprofd_client_api.map.txt b/src/profiling/memory/heapprofd_client_api.map.txt
new file mode 100644
index 0000000..35cd18d
--- /dev/null
+++ b/src/profiling/memory/heapprofd_client_api.map.txt
@@ -0,0 +1,9 @@
+{
+  global:
+    heapprofd_init_session;
+    heapprofd_report_free;
+    heapprofd_register_heap;
+    heapprofd_report_allocation;
+  local:
+    *;
+};
diff --git a/tools/gen_android_bp b/tools/gen_android_bp
index f825363..982fe9c 100755
--- a/tools/gen_android_bp
+++ b/tools/gen_android_bp
@@ -169,6 +169,7 @@
         # is loaded in an __attribute__((constructor)) of libc, we cannot
         # guarantee that the global constructors get run before it is used.
         ('cflags', {'-Wglobal-constructors', '-Werror=global-constructors'}),
+        ('version_script', 'src/profiling/memory/heapprofd_client_api.map.txt'),
     ],
     'heapprofd_client': [
         ('include_dirs', {'bionic/libc'}),
@@ -395,6 +396,7 @@
     self.genrule_headers = set()
     self.genrule_srcs = set()
     self.genrule_shared_libs = set()
+    self.version_script = None
 
   def to_string(self, output):
     if self.comment:
@@ -424,6 +426,7 @@
     self._output_field(output, 'data')
     self._output_field(output, 'stl')
     self._output_field(output, 'apex_available')
+    self._output_field(output, 'version_script')
 
     target_out = []
     self._output_field(target_out, 'android')