ARM: OMAP2+: Prepare to move GPMC to drivers by platform data header
[linux/fpc-iii.git] / arch / x86 / um / elfcore.c
blob7bb89a27a5e43c266583d753e0e270aa73a0ceda
1 #include <linux/elf.h>
2 #include <linux/coredump.h>
3 #include <linux/fs.h>
4 #include <linux/mm.h>
6 #include <asm/elf.h>
9 Elf32_Half elf_core_extra_phdrs(void)
11 return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0;
14 int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
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;
24 for (i = 0; i < ehdrp->e_phnum; ++i) {
25 struct elf_phdr phdr = phdrp[i];
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;
33 phdr.p_paddr = 0; /* match other core phdrs */
34 if (!dump_emit(cprm, &phdr, sizeof(phdr)))
35 return 0;
38 return 1;
41 int elf_core_write_extra_data(struct coredump_params *cprm)
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;
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;
54 if (!dump_emit(cprm, addr, filesz))
55 return 0;
59 return 1;
62 size_t elf_core_extra_data_size(void)
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;
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;
75 return 0;