This is my source:
my_lib_test.so just contains a printf("text")
I want that another ELF executable program that loads this library, could load many other libraries with one only. I don't know if I explained it well.
Well, ok:
ELF executable that loads -> lib.so ->lib.so loads lib2.so, lib2.so etc. right? But with a bash script (I have a 64bit system):
it happens like this:
while if I type
Code:
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
int main(int argc, char **argv) {
void *handle;
double (*cosine)(double);
char *error;
//Loadin all my libs
handle = dlopen ("/test/my_data/my_lib_test.so", RTLD_LAZY);
if (!handle) {
fprintf (stderr, "%s\n", dlerror());
exit(1);
}
dlerror(); /* Clear any existing error */
cosine = dlsym(handle, "cos");
if ((error = dlerror()) != NULL) {
fprintf (stderr, "%s\n", error);
exit(1);
}
printf ("%f\n", (*cosine)(2.0));
dlclose(handle);
return 0;
}
my_lib_test.so just contains a printf("text")
I want that another ELF executable program that loads this library, could load many other libraries with one only. I don't know if I explained it well.
Well, ok:
ELF executable that loads -> lib.so ->lib.so loads lib2.so, lib2.so etc. right? But with a bash script (I have a 64bit system):
Code:
#!/bin/sh
cd /test/my_data/my_elf
env LD_32_PRELOAD="/test/my_data/my_lib_test.so" ./my_elf &
sleep 1
Code:
Cannot open "/test/my_data/my_lib.so"
./my_lib.so
on my shell it writes:
Code:
Segmentation fault (core dumped)