From 18c0e02e2bd53ceedbb843b06ff90890f1c734b0 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 31 Oct 2012 21:27:48 -0400 Subject: add dl_iterate_phdr interface patches by Alex Caudill (npx). the dynamic-linked version is almost identical to the final submitted patch; I just added a couple missing lines for saving the phdr address when the dynamic linker is invoked directly to run a program, and removed a couple to avoid introducing another unnecessary type. the static-linked version is based on npx's draft. it could use some improvements which are contingent on the startup code saving some additional information for later use. --- include/link.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 include/link.h (limited to 'include') diff --git a/include/link.h b/include/link.h new file mode 100644 index 00000000..d5160e7e --- /dev/null +++ b/include/link.h @@ -0,0 +1,27 @@ +#ifndef _LINK_H +#define _LINK_H + +#include +#define __NEED_size_t +#include + +#if UINTPTR_MAX > 0xffffffff +#define ElfW(type) Elf64_ ## type +#else +#define ElfW(type) Elf32_ ## type +#endif + +struct dl_phdr_info { + ElfW(Addr) dlpi_addr; + const char *dlpi_name; + const ElfW(Phdr) *dlpi_phdr; + ElfW(Half) dlpi_phnum; + unsigned long long int dlpi_adds; + unsigned long long int dlpi_subs; + size_t dlpi_tls_modid; + void *dlpi_tls_data; +}; + +int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), void *); + +#endif -- cgit v1.2.1