dlopen

Expose an interface of a class loaded from a framework at runtime

余生长醉 提交于 2019-12-23 06:13:16
问题 I want to load and manipulate SKUIImageColorAnalyzer and SKUIAnalyzedImageColors objects from the private StoreKitUI.framework . First, I attempt to load the framework at runtime: guard case let libHandle = dlopen("/System/Library/PrivateFrameworks/StoreKitUI.framework/StoreKitUI", RTLD_NOW) where libHandle != nil else { fatalError("StoreKitUI not found") } Then, I verify that the SKUIImageColorAnalyzer class can be found: guard let analyzerClass: AnyClass = NSClassFromString(

Linux shared library depends on symbols in another shared library opened by dlopen with RTLD_LOCAL

做~自己de王妃 提交于 2019-12-23 05:13:32
问题 I have a shared library libmain.so , loaded by the host program with dlopen("libmain.so", RTLD_LOCAL) , and under some conditions, libmain.so will load another shared library, libpatch.so , also with dlopen . The problem is, libpatch.so depends on symbols inside libmain.so , so how can I solve this? Change RTLD_LOCAL to RTLD_GLOBAL is not an option due to permission reasons. There is a question quite similar to this one, the solution to that problem is to make libpatch.so a dependency of

c++ dynamic library dlopen error

a 夏天 提交于 2019-12-22 18:52:48
问题 I have two files: RollDice.cpp #include "RollDice.h" #include "./IPlugins.cpp" #include "./IPluginFunctions.cpp" #include <iostream> RollDice::RollDice(IPluginFunctions &iPluginFunctions) : IPlugins(iPluginFunctions) { //srand(time(NULL)); } RollDice::~RollDice() { } void RollDice::callPlugin(std::string paramsText, std::string dataText) { std::cout << "RollDice ;)\n"; } RollDice.h: #ifndef ROLLDICE_H_ #define ROLLDICE_H_ #include "./IPlugins.h" #include "./IPluginFunctions.h" class RollDice:

c++ dynamic library dlopen error

▼魔方 西西 提交于 2019-12-22 18:52:29
问题 I have two files: RollDice.cpp #include "RollDice.h" #include "./IPlugins.cpp" #include "./IPluginFunctions.cpp" #include <iostream> RollDice::RollDice(IPluginFunctions &iPluginFunctions) : IPlugins(iPluginFunctions) { //srand(time(NULL)); } RollDice::~RollDice() { } void RollDice::callPlugin(std::string paramsText, std::string dataText) { std::cout << "RollDice ;)\n"; } RollDice.h: #ifndef ROLLDICE_H_ #define ROLLDICE_H_ #include "./IPlugins.h" #include "./IPluginFunctions.h" class RollDice:

c++ dynamic library dlopen error

爷,独闯天下 提交于 2019-12-22 18:52:15
问题 I have two files: RollDice.cpp #include "RollDice.h" #include "./IPlugins.cpp" #include "./IPluginFunctions.cpp" #include <iostream> RollDice::RollDice(IPluginFunctions &iPluginFunctions) : IPlugins(iPluginFunctions) { //srand(time(NULL)); } RollDice::~RollDice() { } void RollDice::callPlugin(std::string paramsText, std::string dataText) { std::cout << "RollDice ;)\n"; } RollDice.h: #ifndef ROLLDICE_H_ #define ROLLDICE_H_ #include "./IPlugins.h" #include "./IPluginFunctions.h" class RollDice:

How to export specific symbol from executables in GNU/Linux

旧巷老猫 提交于 2019-12-22 12:15:52
问题 While loading dynamic libraries by ::dlopen() , exporting symbols from executables can be done by -rdynamic option, but it exports all the symbols of the executable, which results in bigger binary size. Is there a way to export just specific function(s)? For example, I have testlib.cpp and main.cpp as below: testlib.cpp extern void func_export(int i); extern "C" void func_test(void) { func_export(4); } main.cpp #include <cstdio> #include <dlfcn.h> void func_export(int i) { ::fprintf(stderr, "

How to export specific symbol from executables in GNU/Linux

雨燕双飞 提交于 2019-12-22 12:15:09
问题 While loading dynamic libraries by ::dlopen() , exporting symbols from executables can be done by -rdynamic option, but it exports all the symbols of the executable, which results in bigger binary size. Is there a way to export just specific function(s)? For example, I have testlib.cpp and main.cpp as below: testlib.cpp extern void func_export(int i); extern "C" void func_test(void) { func_export(4); } main.cpp #include <cstdio> #include <dlfcn.h> void func_export(int i) { ::fprintf(stderr, "

Use dlinfo to print all symbols in a library

感情迁移 提交于 2019-12-22 10:22:01
问题 I have a C++ class that uses dlopen to load a library. As an exercise I was trying to dump all of the symbol names from the loaded library. I've used dlinfo to load the linkmap via RTDL_DI_LINKMAP : struct link_map { ElfW(Addr) l_addr; /* Base address shared object is loaded at. */ char *l_name; /* Absolute file name object was found in. */ ElfW(Dyn) *l_ld; /* Dynamic section of the shared object. */ struct link_map *l_next, *l_prev; /* Chain of loaded objects. */ }; This provides me a linked

unable to load library at runtime in android application

核能气质少年 提交于 2019-12-21 05:41:44
问题 I m working on android application in which I used JNI for native c code. I build this application on android 2.0 version and ndkr3 and it works fine. Now when I changed the android sdk version 1.5 and api version 3 I faced problems of unable to open library libtest_demo.so. 05-13 16:54:23.603: INFO/dalvikvm(1211): Unable to dlopen(/data/data/org.abc.test_demo/lib/libtest_demo.so): Cannot find library I put the libtest_demo.so file at the same place /data/data/org.abc.test_demo/lib/libtest

Ld magically overrides statically linked symbols

假如想象 提交于 2019-12-21 05:07:22
问题 For a few days we are dealing with very strange problem. I can't understand how it even happens - when a third-party (MATLAB) program uses our shared library, it somehow overrides some of our symbols (boost, to be precise) with it's own. Those symbols are statically linked and (!!) local. Here is the deal - we use boost 1.47, MATLAB has boost 1.40. Currently, library call segfaults on a call from OUR library to their boost (regex). So, here is the magic: We have no library dependencies, ldd: