POSIX function for accessing code or data in a dynamically-loaded library using the code's name.
Questions tagged [dlsym]
187 questions
-1
votes
1 answer
How do I get a function name in the symbol table to point to a different function?
On MacOS Ventura, obtaining a handle to the dynamic loader using dlopen(NULL, 0) returns a handle containing the entire executable's symbol table. Using this handle, one can obtain pointers to symbol data, access and modify their contents, and these…

jungon
- 41
- 1
- 6
-1
votes
1 answer
Why calling dlopen sometimes breaks my application by damaging class variables content?
I am trying to load library with dlopen().
But call to this dlopen() function sometimes (not always) damages my class variables and then app goes to segmentation fault.
Below is not precise code (pseudocode), but explanation what happens:
class…

nckm
- 103
- 1
- 10
-1
votes
3 answers
Line number of the caller of a preloaded library function
Let's say I have a program (program.c) that uses rand function in standard C library.
1 #include
2 int main(){
3 int rand_number = rand();
4 }
I also have a shared library (intercept.c) that I created to change the behaviour of rand…

M.Soyturk
- 340
- 3
- 14
-1
votes
1 answer
dlopen fails in a library instantiating an object
We have a minimal working example of dlopen that works.
void* lib = dlopen("servlets.so", RTLD_NOW);
void* p = dlsym(lib, "getServlets");
However, if we add another function to the shared library (not even if it is called) then the library does…

Dov
- 8,000
- 8
- 46
- 75
-1
votes
1 answer
Using dlopen/dlsym to open C++ shared library - dlsym returns NULL
I have not yet dealt with shared libraries in C++, and am having some trouble. I want to create a shared library and then have a C function pick up on that library. So here is my shared library file:
extern int nothing();
//sym.cpp
int nothing() {
…

Sidd Singal
- 559
- 6
- 16
-1
votes
1 answer
dlopen for different libraries? C
Hi I am working on a program that works like this:
./Filters File [filters...]
The filters can be a lot of .so libraries that I want to create myself and aply them to the File. But all of the libraries have the same function process(a1,a2,a3), it's…

DavidCG
- 141
- 1
- 1
- 10
-1
votes
1 answer
C dynamic linking to shared libs suppressing/handling "cannot open shared object file" fatal error, and continue linking
I want to link to a shared lib in C. (on Linux)
I want to suppress or handle the:
"error while loading shared libraries: libxxxx.so: cannot open shared object file: No such file or directory"
and continue loading linking to next lib that might…

Yair Karmy
- 31
- 5