dlinfo(3) Library Functions Manual dlinfo(3) dlinfo - (libdl -ldl) #define _GNU_SOURCE #include #include int dlinfo(void *restrict handle, int request, void *restrict info); dlinfo() handle ( dlopen(3) dlmopen(3)). request . info request. request ( info ): RTLD_DI_LMID (Lmid_t *) ( ) handle. RTLD_DI_LINKMAP (struct link_map **) link_map handle. info link_map : struct link_map { ElfW(Addr) l_addr; /* ELF */ char *l_name; /* */ ElfW(Dyn) *l_ld; /* */ struct link_map *l_next, *l_prev; /* */ /* */ }; RTLD_DI_ORIGIN (char *) handle info. RTLD_DI_SERINFO (Dl_serinfo *) handle. info Dl_serinfo . info . RTLD_DI_SERINFOSIZE . : (1) RTLD_DI_SERINFOSIZE Dl_serinfo (dls_size) RTLD_DI_SERINFO . (2) Dl_serinfo (dls_size). (3) RTLD_DI_SERINFOSIZE dls_size dls_cnt . (4) RTLD_DI_SERINFO . Dl_serinfo : typedef struct { size_t dls_size; /* (buffer) */ unsigned int dls_cnt; /* 'dls_serpath' */ Dl_serpath dls_serpath[1]; /* 'dls_cnt' */ } Dl_serinfo; dls_serpath : typedef struct { char *dls_name; /* */ unsigned int dls_flags; /* */ } Dl_serpath; dls_flags . RTLD_DI_SERINFOSIZE (Dl_serinfo *) dls_size dls_cnt Dl_serinfo info RTLD_DI_SERINFO . RTLD_DI_TLS_MODID (size_t *, glibc 2.4) TLS ( ) TLS. TLS *info. RTLD_DI_TLS_DATA (void **, glibc 2.4) TLS TLS . PT_TLS NULL *info. RTLD_DI_PHDR (const ElfW(Phdr *), glibc 2.34.1) *info. dlinfo . dlinfo() 0 ( ) . -1 dlerror(3). attributes(7). +------------+------------------------------------+--------------------+ || | | +------------+------------------------------------+--------------------+ |dlinfo() | | MT-Safe | +------------+------------------------------------+--------------------+ . GNU. glibc 2.3.3. Solaris. dlopen(3) RTLD_DI_SERINFOSIZE RTLD_DI_SERINFO . : $ ./a.out /lib64/libm.so.6; dls_serpath[0].dls_name = /lib64 dls_serpath[1].dls_name = /usr/lib64 #define _GNU_SOURCE #include #include #include #include int main(int argc, char *argv[]) { void *handle; Dl_serinfo serinfo; Dl_serinfo *sip; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(EXIT_FAILURE); } /* Obtain a handle for shared object specified on command line. */ handle = dlopen(argv[1], RTLD_NOW); if (handle == NULL) { fprintf(stderr, "dlopen() failed: %s\n", dlerror()); exit(EXIT_FAILURE); } /* Discover the size of the buffer that we must pass to RTLD_DI_SERINFO. */ if (dlinfo(handle, RTLD_DI_SERINFOSIZE, &serinfo) == -1) { fprintf(stderr, "RTLD_DI_SERINFOSIZE failed: %s\n", dlerror()); exit(EXIT_FAILURE); } /* Allocate the buffer for use with RTLD_DI_SERINFO. */ sip = malloc(serinfo.dls_size); if (sip == NULL) { perror("malloc"); exit(EXIT_FAILURE); } /* Initialize the 'dls_size' and 'dls_cnt' fields in the newly allocated buffer. */ if (dlinfo(handle, RTLD_DI_SERINFOSIZE, sip) == -1) { fprintf(stderr, "RTLD_DI_SERINFOSIZE failed: %s\n", dlerror()); exit(EXIT_FAILURE); } /* Fetch and print library search list. */ if (dlinfo(handle, RTLD_DI_SERINFO, sip) == -1) { fprintf(stderr, "RTLD_DI_SERINFO failed: %s\n", dlerror()); exit(EXIT_FAILURE); } for (size_t j = 0; j < serinfo.dls_cnt; j++) printf("dls_serpath[%zu].dls_name = %s\n", j, sip->dls_serpath[j].dls_name); exit(EXIT_SUCCESS); } dl_iterate_phdr(3), dladdr(3), dlerror(3), dlopen(3), dlsym(3), ld.so(8) 3 . . : . 6.18 8 2026 dlinfo(3)