enabling caching for dl_iterate_phdr()

Jakub Jelinek jakub@redhat.com
Thu Jan 22 08:39:00 GMT 2004


On Wed, Jan 21, 2004 at 04:35:49PM -0800, David Mosberger wrote:
> --- elf/link.h	16 Sep 2003 05:48:04 -0000	1.76
> +++ elf/link.h	22 Jan 2004 00:26:54 -0000
> @@ -100,6 +100,12 @@
>      const char *dlpi_name;
>      const ElfW(Phdr) *dlpi_phdr;
>      ElfW(Half) dlpi_phnum;
> +
> +    /* Note: older versions of libc do not provide the following
> +       members.  Check the SIZE argument pass to the dl_iterate_phdr()
> +       callback to determine whether or not they areprovided.  */
> +    unsigned int dlpi_adds; /* incremented when phdrs may have been added */
> +    unsigned int dlpi_subs; /* incremented when phdrs may have been removed */

I'd make the counters unsigned long long instead to avoid wrap around.

Also, could you write a testcase for it? dl_iterate_phdr, then dlopen some
shlib in elf, then dl_iterate_phdr again, check the counters, dlclose
etc.

	Jakub



More information about the Libc-hacker mailing list