summaryrefslogtreecommitdiff
path: root/libexec/ld.so
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2004-10-14 10:02:29 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2004-10-14 10:02:29 +0000
commit7f502d6d8a7b5e36e7343a3df02b69255f9f1edc (patch)
treefda9ec0d6ab6bbc83b4caed44f4ecbfc522bccda /libexec/ld.so
parent96b74c54bf150f0e647296c3003a012c8e3e4672 (diff)
Add dl_iterate_phdr() support.
ok drahn@, millert@
Diffstat (limited to 'libexec/ld.so')
-rw-r--r--libexec/ld.so/dlfcn.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/libexec/ld.so/dlfcn.c b/libexec/ld.so/dlfcn.c
index dda9821a350..6b534ec2c8b 100644
--- a/libexec/ld.so/dlfcn.c
+++ b/libexec/ld.so/dlfcn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dlfcn.c,v 1.40 2004/08/13 16:45:41 drahn Exp $ */
+/* $OpenBSD: dlfcn.c,v 1.41 2004/10/14 10:02:28 kettenis Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -386,6 +386,33 @@ _dl_thread_kern_go(void)
(*_dl_thread_fnc)(1);
}
+int
+dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *data),
+ void *data)
+{
+ elf_object_t *object;
+ Elf_Ehdr *ehdr;
+ struct dl_phdr_info info;
+ int retval = -1;
+
+ for (object = _dl_objects; object != NULL; object = object->next) {
+ ehdr = (Elf_Ehdr *)object->load_addr;
+ if (ehdr == NULL)
+ continue;
+
+ info.dlpi_addr = object->load_addr;
+ info.dlpi_name = object->load_name;
+ info.dlpi_phdr =
+ (Elf_Phdr *)((char *)object->load_addr + ehdr->e_phoff);
+ info.dlpi_phnum = ehdr->e_phnum;
+ retval = callback(&info, sizeof (struct dl_phdr_info), data);
+ if (retval)
+ break;
+ }
+
+ return retval;
+}
+
static elf_object_t *
obj_from_addr(const void *addr)
{