C - What library (.so file) is the c function open() in, and how would I find that out for an arbitrary function? -


how can find library function open() is? like, name of actual "xxxxxx.so" file contains function? also, there place typically information other functions?

i didn't know how find library given function in, required dlopen

knowing library not required dlopen():

if file null pointer, dlopen() shall return global symbol table handle running process image. symbol table handle shall provide access symbols ordered set of executable object files consisting of original program image file, executable object files loaded @ program start-up specified process file (for example, shared libraries), , set of executable object files loaded using dlopen() operations rtld_global flag. …

but if want know:

#define _gnu_source #include <stdio.h> #include <stdlib.h> #include <dlfcn.h>  int main() {     // don't need know library dlopen():     void *handle = dlopen(null, rtld_now);     if (!handle) puts(dlerror()), exit(1);     void *p = dlsym(handle, "open");     char *s = dlerror();     if (s) puts(s), exit(1);     printf("open = %p\n", p);      // can find library glibc extension:     dl_info info;     if (dladdr(p, &info))         printf("%s contains %s\n", info.dli_fname, info.dli_sname); } 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -