Reputation: 777
Is it possible using the Dynamically Loaded (DL) Libraries in c, to retrieve the address of the first instruction of the library? In other words I'd want to know the address from where the library has been loaded.
Upvotes: 2
Views: 67
Reputation: 36
There are a few ways to do it:
Use the glibc extension dladdr to get information about any exported function from the shared object. You need to have the name of an exported symbol to do this, though. It returns a Dl_info structure containing, amongst other things, the base address at which the object has been loaded. See 'man dladdr' for more details.
Read and parse /proc/self/maps, looking for your library and noting the starting address of the segment that has the executable bit set ('x' in permissions).
Upvotes: 1