Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] Finding .so's path from inside the .so at runtime?

On Fri, Feb 25, 2005 at 11:17:48AM +1100, amos@xxxxxxxxxxxxxxxxxx wrote:
> Is there a standard way for a .so file to find where it was loaded from?

from man dl_iterate_phdr 

  The info argument is a structure of the following type:

         struct dl_phdr_info {
           ElfW(Addr)        dlpi_addr;  /* Base address of object */
           const char       *dlpi_name;  /* (Null-terminated) name of
           const ElfW(Phdr) *dlpi_phdr;  /* Pointer to array of
                                            ELF program headers
                                            for this object */
           ElfW(Half)        dlpi_phnum; /* # of items in 'dlpi_phdr' */

  The dlpi_name field is a null-terminated string giving the path-name
  from which the shared object was loaded.


Attachment: signature.asc
Description: Digital signature