Merge "Rename target.linux[_x86[_64]] to target.linux_glibc[_x86[_64]]"
am: 2f3380574e
Change-Id: I5dfaf7f7e287aa00c35928852ee3461396861cfd
diff --git a/tools/bcc/Android.bp b/tools/bcc/Android.bp
index b4e8f2d..eecd44d 100644
--- a/tools/bcc/Android.bp
+++ b/tools/bcc/Android.bp
@@ -33,6 +33,7 @@
android: {
shared_libs: [
"liblog",
+ "libvndksupport",
],
},
},
diff --git a/tools/bcc/Main.cpp b/tools/bcc/Main.cpp
index 3887bd9..e1d3096 100644
--- a/tools/bcc/Main.cpp
+++ b/tools/bcc/Main.cpp
@@ -44,6 +44,10 @@
#include <bcc/RSCompilerDriver.h>
#include <bcc/Source.h>
+#ifdef __ANDROID__
+#include <vndksupport/linker.h>
+#endif
+
using namespace bcc;
#define STR2(a) #a
@@ -121,6 +125,13 @@
" cache invalidation at a later time"),
llvm::cl::value_desc("checksum"));
+#ifdef __ANDROID__
+llvm::cl::opt<std::string>
+OptVendorPlugin("plugin", llvm::cl::ZeroOrMore,
+ llvm::cl::value_desc("pluginfilename"),
+ llvm::cl::desc("Load the specified vendor plugin. Use this instead of the -load option"));
+#endif
+
//===----------------------------------------------------------------------===//
// Compiler Options
//===----------------------------------------------------------------------===//
@@ -288,6 +299,21 @@
return EXIT_FAILURE;
}
+#ifdef __ANDROID__
+ if (!OptVendorPlugin.empty()) {
+ // bcc is a system process and the vendor plugin is a vendor lib. Since the
+ // vendor lib might have been compiled using the old versions of platform
+ // libraries, they must not be directly loaded into the default namespace
+ // but into the sphal namespace where old versions of platform libraries
+ // (aka VNDK libs) are provided.
+ void* handle = android_load_sphal_library(OptVendorPlugin.c_str(), RTLD_LAZY|RTLD_GLOBAL);
+ if (handle == nullptr) {
+ ALOGE("Failed to load vendor plugin %s", OptVendorPlugin.c_str());
+ return EXIT_FAILURE;
+ }
+ }
+#endif
+
if (!ConfigCompiler(RSCD)) {
ALOGE("Failed to configure compiler");
return EXIT_FAILURE;