dlopen

RTLD_LOCAL and dynamic_cast on Linux

☆樱花仙子☆ 提交于 2019-12-04 11:34:43
We have a plugin that is constructed of a few shared libraries in our application that we need to update while the application is running. For performance reasons we load and start using the new plugin before unloading the old plugin and only when all threads are done using the old plugin we unload it. Since the libraries of the new plugin and the old plugin have the same symbols in them we dlopen() with RTLD_LOCAL . If we don't the new plugin call from internal functions by accident to symbols from the old plugin. One library of the plugin does dynamic_cast() to an object that was created by

Loading Linux libraries at runtime

☆樱花仙子☆ 提交于 2019-12-04 10:49:20
I think a major design flaw in Linux is the shared object hell when it comes to distributing programs in binary instead of source code form. Here is my specific problem: I want to publish a Linux program in ELF binary form that should run on as many distributions as possible so my mandatory dependencies are as low as it gets: The only libraries required under any circumstances are libpthread, libX11, librt and libm (and glibc of course). I'm linking dynamically against these libraries when I build my program using gcc. Optionally, however, my program should also support ALSA (sound interface),

dlopen a dynamic library from a static library, when the dynamic library uses symbols of the static one

北慕城南 提交于 2019-12-04 09:56:58
This question is closely related to dlopen a dynamic library from a static library linux C++ , but contains a further complication (and uses C++ instead of C): I have an application that links against a static library (.a) and that library uses the dlopen function to load dynamic libraries (.so). In addition, the dynamic libraries call functions defined in the static one. Is there a way to compile this without linking the dynamic libraries against the static one or vice versa? Here comes what I tried so far, slightly modifying the example from the related question: app.cpp: #include "staticlib

How to intercept file system access inside dlopen()?

…衆ロ難τιáo~ 提交于 2019-12-04 06:38:06
I want to intercept all file system access that occurs inside of dlopen(). At first, it would seem like LD_PRELOAD or -Wl,-wrap, would be viable solutions, but I have had trouble making them work due to some technical reasons: ld.so has already mapped its own symbols by the time LD_PRELOAD is processed. It's not critical for me to intercept the initial loading, but the _dl_* worker functions are resolved at this time, so future calls go through them. I think LD_PRELOAD is too late. Somehow malloc circumvents the issue above because the malloc() inside of ld.so does not have a functional free()

Dynamic loading of shared objects using dlopen()

扶醉桌前 提交于 2019-12-03 21:04:06
问题 I'm working on a plain X11 app. By default, my app only requires libX11.so and the standard gcc C and math libs. The App can extend features with Xfixes, Xrender and ALSA sound system. However, these (Xfixes, Xrender and ALSA) feature are optional. To achieve this behavior, I am using run time loading i.e., libXfixes, libXrender and libasound shall be dlopen()ed. Hence the App can function in absence of such libraries. Now my question: What library names should I use when calling dlopen()? I

unable to load library at runtime in android application

心不动则不痛 提交于 2019-12-03 17:21:24
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_demo.so but still the same problem arises. In my java file I called native libraries like, System

Ld magically overrides statically linked symbols

痴心易碎 提交于 2019-12-03 15:51:09
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: linux-vdso.so.1 => (0x00007fff4abff000) libpthread.so.0 => /lib/libpthread.so.0 (0x00007f1a3fd65000)

dlopen() search path

你离开我真会死。 提交于 2019-12-03 15:49:34
is there a way to find out programmatically which paths are searched by dlopen() for shared objects? I always thought dlopen() would only look in /lib and /usr/lib but now I've seen that on Linux Mint several core components like libglib-2.0.so are in a wholly different folders, namely in /rofs/lib/i386-gnu-linux and some others. Is there a way to get to know all these paths that dlopen() will search through for a shared object? I already checked the environment variable LD_LIBRARY_PATH but it's not defined at all. look at the ldconfig man page, and the file: /etc/ld.so.conf In addition of the

Destructor of a global static variable in a shared library is not called on dlclose

China☆狼群 提交于 2019-12-03 13:44:11
In a main program, I dlopen and dlclose ( LoadLibrary and FreeLibrary respectively) a shared library. The shared library contains a static variable that is instantiated upon dlopen , and destroyed upon dlclose . This behavior is consistent on MSVC 2008 and 2013, GCC 3.4.6, and Sunstudio 12.1. With GCC 4.9.1 and GCC 5.2.1 however, the destructor was no longer called on dlclose . Instead, it was called before program exit. The particularity of the static variable's class, is that in the constructor, there is a call to a templated function get (of global scope) that returns a local static

dlopen failed: cannot locate symbol “signal”

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am developing an Android app using NDK. I have built OpenSSL as static libraries, libcrypto.a and libssl.a, which I linked with my custom C code. When I try to load the library at runtime I get: dlopen failed: cannot locate symbol "signal"... Any idea how to fix this? Thanks! Update: This comes from libcrypto: libcrypto.a: 00000000 *UND* 00000000 signal In my .so I see: libtest.so: NEEDED libc.so ... 00040240 <signal@plt>: 40240: e28fc601 add ip, pc, #1048576 ; 0x100000 40244: e28cca80 add ip, ip, #128, 20 ; 0x80000 40248: e5bcfd64 ldr pc,