diff options
| author | Peter Wemm <peter@FreeBSD.org> | 2002-09-13 16:33:35 +0000 |
|---|---|---|
| committer | Peter Wemm <peter@FreeBSD.org> | 2002-09-13 16:33:35 +0000 |
| commit | e0491636b54ff7b4eaa790bf3dda120f477f8f52 (patch) | |
| tree | b2153d434adbf0e393a7271db2de6d3a906ea97a /usr.bin/gcore/elfcore.c | |
| parent | af656bf76bf3cbee12d0270c88e212525809d01c (diff) | |
Notes
Diffstat (limited to 'usr.bin/gcore/elfcore.c')
| -rw-r--r-- | usr.bin/gcore/elfcore.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c index 83f68a94fb11..0881ceb3682e 100644 --- a/usr.bin/gcore/elfcore.c +++ b/usr.bin/gcore/elfcore.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/procfs.h> +#include <sys/linker_set.h> #include <machine/elf.h> #include <vm/vm_param.h> #include <vm/vm.h> @@ -77,11 +78,26 @@ static void freemap(vm_map_entry_t); static void readhdrinfo(pid_t, prstatus_t *, prfpregset_t *, prpsinfo_t *); static vm_map_entry_t readmap(pid_t); +static int +elf_ident(int efd, pid_t pid, char *binfile) +{ + Elf_Ehdr hdr; + int cnt; + uid_t uid; + + cnt = read(efd, &hdr, sizeof(hdr)); + if (cnt != sizeof(hdr)) + return (0); + if (IS_ELF(hdr)) + return (1); + return (0); +} + /* * Write an ELF coredump for the given pid to the given fd. */ void -elf_coredump(int fd, pid_t pid) +elf_coredump(int efd, int fd, pid_t pid) { vm_map_entry_t map; struct sseg_closure seginfo; @@ -357,6 +373,7 @@ elf_putnote(void *dst, size_t *off, const char *name, int type, static void freemap(vm_map_entry_t map) { + while (map != NULL) { vm_map_entry_t next = map->next; free(map); @@ -514,3 +531,6 @@ readmap(pid_t pid) free(mapbuf); return map; } + +struct dumpers elfdump = { elf_ident, elf_coredump }; +TEXT_SET(dumpset, elfdump); |
