dlopen

_dl_close Assertion failure

I'm using dlopen() in an Apache module that I am writing so that I can have a plugin system for my module. I've found that if I compile my module, compile my plugin, and start Apache, everything works peachy-keen. If, however, after I have done all that, I recompile my plugin, (making a small change or two to the plugins code,) my next ...

How would a loaded library function call a symbol in the main application?

When loaded a shared library is opened via the function dlopen(), is there a way for it to call functions in main program? ...

dlopen on library with static member that throws exception in constructor - results in Abort

I am trying to load a dynamic library using dlopen function. This library contains a static object, which throws an exception in its constructor. I have a "try-catch(...)" block around the dlopen call, but it doesn't catch the exception, and I just see "Abort" printed. How am I able to catch this exception? ...

dlopen() issue

I'm writing some code that uses dynamic shared libraries as plugins. My command line for building the shared libraries looks like: cc -shared -fPIC -o module.so -g -Wall module.c Within the module, I can call functions that are in any other shared library that has been loaded within the main executable. However I cannot access (expo...

Python dlopen/dlfunc/dlsym wrappers

Anybody knows if actually exists a wrapper or ported library to access to Unix dynamic linker on Python? ...

Portability of dlfunc?

I'm reading through the manpage for dlopen and friends on FreeBSD. I'm working on a cross-platform application that is using shared libraries for loadable plugins. I've never done this before, but I think I have a decent grasp of how it works. The manpage mentions dlsym(), which appears to be the common means of getting a function pointe...

Error on dlopen: St9bad_alloc

I have some c++ code I'm using for testing in which the first line is a call to dlopen in an attempt to load my shared object. Upon hitting this line I get the following error: Terminate called after throwing an instance of std::bad_alloc: what() : St9bad_alloc I've upped the memory (free -m now reports that I have ~120 MB free wh...

dlsym/dlopen with runtime arguments

Hello, I am trying to do something like the following enum types {None, Bool, Short, Char, Integer, Double, Long, Ptr}; int main(int argc, char ** args) { enum types params[10] = {0}; void* triangle = dlopen("./foo.so", RTLD_LAZY); void * fun = dlsym(triangle, ars[1]); <<pseudo code>> } Where pseudo code is ...

building a .so that is also an executable

So everyone probably knows that glibc's /lib/libc.so.6 can be executed in the shell like a normal executable in which cases it prints its version information and exits. This is done via defining an entry point in the .so. For some cases it could be interesting to use this for other projects too. Unfortunately, the low-level entry point y...

Memory leak reported by valgrind in dlopen?

I've been debugging some app lately with valgrind, and I'm getting very weird reports from dlopen. ==1987== 32 bytes in 1 blocks are still reachable in loss record 1 of 2 ==1987== at 0x4C24477: calloc (vg_replace_malloc.c:418) ==1987== by 0x570F31F: _dlerror_run (dlerror.c:142) ==1987== by 0x570EEE0: dlopen@@GLIBC_2.2.5 (dlopen...

Using dlopen, how can I cope with changes to the library file I have loaded?

I have a program written in C++ which uses dlopen to load a dynamic library (Linux, i386, .so). When the library file is subsequently modified, my program tends to crash. This is understandable, since presumably the file is simply mapped into memory. My question is: other than simply creating myself a copy of the file and dlopening th...

linux dlopen: can a library be "notified" when it is loaded?

Is there a way for a shared library to be "notified" when it is loaded? In other words, let's say I use dlopen on a shared library, is there a function that is automatically called (if present) on the shared library (e.g. main?) ...

library path when dynamically loaded?

How can I get the path of the shared library from within the library itself? In other words, let's say that library X is loaded using dlopen(), how can I get access to the path that was used to load the said library from within the library itself? Note that I cannot have the agent that loaded the library in the first place hand me this...

Disabling access to "exec" functions ?

Let's say I have a process "A" that loads a dynamic library "L". Q: Is there a way to disable access to the "exec" functions to functions inside "L"? ...

[OS X] What can cause dlopen: no suitable image found (can't map)?

What can cause the following error when loading an additional bundle using dlopen: dlopen($(OBJ_DIR)/Test-20091217211256.ob, 6): no suitable image found. Did find: $(OBJ_DIR)/Test-20091217211256.ob: can't map Before this error, the process allocates large amounts of memory. (Substituted $(OBJ_DIR) in the error for the actual pat...

Finding dylib version using dlopen

Is there a way to find the version of a dylib using its path? I am looking for something that accepts the same arguments as dlopen. I have looked at NSVersionOfRunTimeLibrary, but from my reading of the documentation it looks like it gets the version of the current dylib, not the one specified in the path. Thank you ...

dynamic_cast fails when used with dlopen/dlsym

Intro Let me apologise upfront for the long question. It is as short as I could make it, which is, unfortunately, not very short. Setup I have defined two interfaces, A and B: class A // An interface { public: virtual ~A() {} virtual void whatever_A()=0; }; class B // Another interface { public: virtual ~B() {} virtual voi...

How to find shared objects loaded during startup of an application?

Hi, I know that using dlopen with RLTD_NOLOAD one can find out whether a shared object is already loaded or not. This, however, doesn't seem to work if a so is linked to the executable and loaded by the linker during application startup. I mean, lets say I have mylib.so and load it with dlopen. Later, if I make dlopen with RLTD_NOLOAD,...

dlopen / dlsym with as little linking as possible

I have an application which can make use of plugins which are loaded at runtime using dlopen. Each of the plugins defines a function toretrieve the plugin information which is defined using a common structure. Something like that: struct plugin { char *name; char *app_version; int app_verion_id; char *plugin_version; ...

Static Class Variables in Dynamic Library and Main Program

I am working on a project that has a class 'A' that contains a static stl container class. This class is included in both my main program and a .so file. The class uses the default(implicit, not declared) constructor/destructor. The main program loads the .so file using dlopen() and in its destructor, calls dlclose(). The program cra...