Merge tag 'iio-for-4.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio...
[deliverable/linux.git] / arch / x86 / um / elfcore.c
CommitLineData
1fcccbac
DH
1#include <linux/elf.h>
2#include <linux/coredump.h>
3#include <linux/fs.h>
4#include <linux/mm.h>
5
6#include <asm/elf.h>
7
8
9Elf32_Half elf_core_extra_phdrs(void)
10{
11 return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0;
12}
13
506f21c5 14int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
1fcccbac
DH
15{
16 if ( vsyscall_ehdr ) {
17 const struct elfhdr *const ehdrp =
18 (struct elfhdr *) vsyscall_ehdr;
19 const struct elf_phdr *const phdrp =
20 (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff);
21 int i;
22 Elf32_Off ofs = 0;
23
24 for (i = 0; i < ehdrp->e_phnum; ++i) {
25 struct elf_phdr phdr = phdrp[i];
26
27 if (phdr.p_type == PT_LOAD) {
28 ofs = phdr.p_offset = offset;
29 offset += phdr.p_filesz;
30 } else {
31 phdr.p_offset += ofs;
32 }
33 phdr.p_paddr = 0; /* match other core phdrs */
506f21c5 34 if (!dump_emit(cprm, &phdr, sizeof(phdr)))
1fcccbac
DH
35 return 0;
36 }
37 }
38 return 1;
39}
40
aa3e7eaf 41int elf_core_write_extra_data(struct coredump_params *cprm)
1fcccbac
DH
42{
43 if ( vsyscall_ehdr ) {
44 const struct elfhdr *const ehdrp =
45 (struct elfhdr *) vsyscall_ehdr;
46 const struct elf_phdr *const phdrp =
47 (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff);
48 int i;
49
50 for (i = 0; i < ehdrp->e_phnum; ++i) {
51 if (phdrp[i].p_type == PT_LOAD) {
52 void *addr = (void *) phdrp[i].p_vaddr;
53 size_t filesz = phdrp[i].p_filesz;
aa3e7eaf 54 if (!dump_emit(cprm, addr, filesz))
1fcccbac
DH
55 return 0;
56 }
57 }
58 }
59 return 1;
60}
8d9032bb
DH
61
62size_t elf_core_extra_data_size(void)
63{
64 if ( vsyscall_ehdr ) {
65 const struct elfhdr *const ehdrp =
66 (struct elfhdr *)vsyscall_ehdr;
67 const struct elf_phdr *const phdrp =
68 (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff);
69 int i;
70
71 for (i = 0; i < ehdrp->e_phnum; ++i)
72 if (phdrp[i].p_type == PT_LOAD)
73 return (size_t) phdrp[i].p_filesz;
74 }
75 return 0;
76}
This page took 0.450624 seconds and 5 git commands to generate.