1 /* Get loaded objects program headers.
3 Based on GNU C library (file: libc/elf/dl-iteratephdr.c)
5 Copyright (C) 2001,2002,2003,2004,2006,2007 Free Software Foundation, Inc.
6 Contributed by Jakub Jelinek <jakub@redhat.com>, 2001.
8 Copyright (C) 2008 STMicroelectronics Ltd.
9 Author: Carmelo Amoroso <carmelo.amoroso@st.com>
11 Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
18 /* we want this in libc but nowhere else */
22 __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info, size_t size, void *data), void *data)
25 #ifndef __ARCH_HAS_NO_SHARED__
26 struct elf_resolve *l;
27 struct dl_phdr_info info;
29 for (l = _dl_loaded_modules; l != NULL; l = l->next) {
30 info.dlpi_addr = l->loadaddr;
31 info.dlpi_name = l->libname;
32 info.dlpi_phdr = l->ppnt;
33 info.dlpi_phnum = l->n_phent;
34 ret = callback (&info, sizeof (struct dl_phdr_info), data);
44 weak_alias(__dl_iterate_phdr, dl_iterate_phdr)
48 /* dl-support.c defines these and initializes them early on. */
49 extern ElfW(Phdr) *_dl_phdr;
50 extern size_t _dl_phnum;
53 dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
54 size_t size, void *data), void *data)
58 /* This entry describes this statically-linked program itself. */
59 struct dl_phdr_info info;
61 #if defined(__FDPIC__)
62 info.dlpi_addr.map = NULL;
63 info.dlpi_addr.got_value = NULL;
64 #elif defined(__DSBT__)
65 info.dlpi_addr.map = NULL;
70 info.dlpi_phdr = _dl_phdr;
71 info.dlpi_phnum = _dl_phnum;
72 ret = (*callback) (&info, sizeof (struct dl_phdr_info), data);
76 /* Then invoke callback on loaded modules, if any */
77 return __dl_iterate_phdr (callback, data);