OSDN Git Service

Do not link stub libraries from all namespaces
authorKiyoung Kim <kiyoungkim@google.com>
Fri, 15 May 2020 05:26:23 +0000 (14:26 +0900)
committerKiyoung Kim <kiyoungkim@google.com>
Mon, 18 May 2020 07:47:48 +0000 (16:47 +0900)
In current linkerconfig from all namespaces stub libraries are linked to
system namespace, which was required for APEX namespaces. However, as
linkerconfig checks dependencies from APEX namespaces now, this link is
excessive and can create unexpected interface from system. This change
removes redundant stub library link so namespaces can link to system
image with minimum set of libraries.

Bug: 156563692
Test: m -j passed && crosshatch_hwasasn booted
Change-Id: If43c954f376ede65bd2c3f682be6ae5d6866d3df

contents/common/system_links.cc

index 08c88f7..5dc9953 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include "linkerconfig/common.h"
 
 #include <string>
 #include <vector>
 
 #include <android-base/strings.h>
 
-#include "linkerconfig/common.h"
 #include "linkerconfig/context.h"
 #include "linkerconfig/section.h"
 #include "linkerconfig/variables.h"
 
+namespace {
+const std::vector<std::string> kBionicLibs = {
+    "libc.so",
+    "libdl.so",
+    "libdl_android.so",
+    "libm.so",
+};
+}  // namespace
+
 namespace android {
 namespace linkerconfig {
 namespace contents {
@@ -36,10 +45,10 @@ void AddStandardSystemLinks(const Context& ctx, Section* section) {
   const bool is_section_vndk_enabled = ctx.IsSectionVndkEnabled();
   section->ForEachNamespaces([&](Namespace& ns) {
     if (ns.GetName() != system_ns_name) {
+      ns.GetLink(system_ns_name).AddSharedLib(kBionicLibs);
       if (!is_section_vndk_enabled || ns.GetName() != "default") {
         ns.GetLink(system_ns_name)
-            .AddSharedLib(Var("STUB_LIBRARIES"),
-                          Var("SANITIZER_RUNTIME_LIBRARIES"));
+            .AddSharedLib(Var("SANITIZER_RUNTIME_LIBRARIES"));
       }
     }
   });