diff options
author | Jiyong Park <jiyong@google.com> | 2017-06-14 02:40:11 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-06-14 02:40:11 +0000 |
commit | 5895d861c4b7645a6b9aab70f18992f64bf11374 (patch) | |
tree | bd0250c21e5e4bbbc60bbeadcbf5349db043e7f4 | |
parent | bd03e4a1e25b25c7ff80f72d2746da20d192078c (diff) | |
parent | 16d5c52c5e6b9afc6195870f6399bf6cca834064 (diff) | |
download | libbcc-5895d861c4b7645a6b9aab70f18992f64bf11374.tar.gz |
bcc vendor plugin must be loaded from the sphal namespace
am: 16d5c52c5e
Change-Id: I765f60bddfec2b798bd9a1407f314792de9da9a9
-rw-r--r-- | tools/bcc/Android.bp | 1 | ||||
-rw-r--r-- | tools/bcc/Main.cpp | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tools/bcc/Android.bp b/tools/bcc/Android.bp index 507fdd9..63729fd 100644 --- a/tools/bcc/Android.bp +++ b/tools/bcc/Android.bp @@ -37,6 +37,7 @@ cc_binary { shared_libs: [ "libdl", "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 @@ OptChecksum("build-checksum", " 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 @@ int main(int argc, char **argv) { 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; |