简体   繁体   中英

glibc - get handle to shared library having symbol containing specified address

Something like dladdr that gives me a dynamic library handle to the shared object or a way to get the handle from the shared object's base address. The file containing the shared object may have been moved or deleted so no, I can't dlopen() the filename given by dladdr.

glibc's dlopen handles are based on link_map. I can iterate all link_map's and see if one has l_addr equal to the one given by dladdr. The address of that link_map is the handle.

dietlibc also uses link_map's as handles.

In the case of uClibc there is another struct - dyn_elf. It contains a pointer to a link_map. The global variable _dl_symbol_tables has a pointer to the head of a linked list of dyn_elf's.

bionic uses its own struct which contains struct link_map as a member (not a pointer).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM