OSDN Git Service

Fix for default library path "/vendor/lib"
authorneo.chae <neo.chae@lge.com>
Tue, 4 Oct 2016 02:00:27 +0000 (11:00 +0900)
committerDimitry Ivanov <dimitry@google.com>
Wed, 5 Oct 2016 10:15:49 +0000 (03:15 -0700)
Android N restrict which libraries C/C++ code
can link against at runtime.

If device has a vendor partition
then /system/vendor symlink to /vendor.
Otherwise /vendor symlink to /system/vendor.

But is_system_library() is only checking /vendor/lib.
It will return false for /system/vendor/lib path.
It is need to add a real path to default library path.

Similarily, default ld library path is already checking.
parse_LD_LIBRARY_PATH()->parse_path()->resolve_paths()

Test: build bionic and run bionic-unit-tests
Bug: http://b/31919547
Change-Id: Ie6777e2b02729948ce77a94de32343d40358bf2c
Signed-off-by: Hyangseok Chae <neo.chae@lge.com>
linker/linker.cpp

index fab64bc..b2e8dbc 100644 (file)
@@ -3215,9 +3215,14 @@ void init_default_namespace() {
     g_default_ld_paths = kDefaultLdPaths;
   }
 
+  char real_path[PATH_MAX];
   std::vector<std::string> ld_default_paths;
   for (size_t i = 0; g_default_ld_paths[i] != nullptr; ++i) {
-    ld_default_paths.push_back(g_default_ld_paths[i]);
+    if (realpath(g_default_ld_paths[i], real_path) != nullptr) {
+      ld_default_paths.push_back(real_path);
+    } else {
+      ld_default_paths.push_back(g_default_ld_paths[i]);
+    }
   }
 
   g_default_namespace.set_default_library_paths(std::move(ld_default_paths));