OSDN Git Service

Add system link for libfdtrack.so
authorJosh Gao <jmgao@google.com>
Fri, 15 May 2020 23:04:23 +0000 (16:04 -0700)
committerJosh Gao <jmgao@google.com>
Tue, 19 May 2020 21:23:27 +0000 (14:23 -0700)
libfdtrack.so is currently a library on the system image that's used via
dlopen to debug file descriptor leaks. We may want to move this into the
runtime module, but for now, add it as a system link.

Bug: http://b/151688751
Bug: http://b/156571476
Test: added dlopen to adbd
Change-Id: I21ebfe04d7ad85149e4df8a40911efd94ce5cf94

contents/common/system_links.cc

index 5dc9953..0cdeeb9 100644 (file)
@@ -18,6 +18,7 @@
 #include <string>
 #include <vector>
 
+#include <android-base/properties.h>
 #include <android-base/strings.h>
 
 #include "linkerconfig/context.h"
@@ -41,6 +42,7 @@ using android::linkerconfig::modules::Namespace;
 using android::linkerconfig::modules::Section;
 
 void AddStandardSystemLinks(const Context& ctx, Section* section) {
+  const bool debuggable = android::base::GetBoolProperty("ro.debuggable", false);
   const std::string system_ns_name = ctx.GetSystemNamespaceName();
   const bool is_section_vndk_enabled = ctx.IsSectionVndkEnabled();
   section->ForEachNamespaces([&](Namespace& ns) {
@@ -50,6 +52,10 @@ void AddStandardSystemLinks(const Context& ctx, Section* section) {
         ns.GetLink(system_ns_name)
             .AddSharedLib(Var("SANITIZER_RUNTIME_LIBRARIES"));
       }
+      if (debuggable) {
+        // Library on the system image that can be dlopened for debugging purposes.
+        ns.GetLink(system_ns_name).AddSharedLib("libfdtrack.so");
+      }
     }
   });
 }