dlopen() and -pg flag
Sergey Lyubka
devnull at uptsoft.com
Wed Dec 3 02:17:05 PST 2003
Below is a little snipper that tries to dlopen(argv[1]).
It works fine until it is compiled with profiling support, -pg flag.
Compiled with -pg, dlopen() reports "Service unavailable".
How to fix that ?
-sergey
#include <dlfcn.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
void *handle, *sym;
if (argc > 1) {
handle = dlopen(argv[1], RTLD_NOW);
if (handle == NULL) {
fprintf(stderr, "dlopen: %s\n", dlerror());
} else {
fprintf(stderr, "handle: %p\n", handle);
if (argc > 2) {
sym = dlsym(handle, argv[2]);
fprintf(stderr, "%s: %p\n", argv[2], sym);
}
}
}
return (EXIT_SUCCESS);
}
More information about the freebsd-hackers
mailing list