Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Support for 32-bit Linux/Parisc ELF binaries on 64 bit kernels |
| 3 | * |
| 4 | * Copyright (C) 2000 John Marvin |
| 5 | * Copyright (C) 2000 Hewlett Packard Co. |
| 6 | * |
| 7 | * Heavily inspired from various other efforts to do the same thing |
| 8 | * (ia64,sparc64/mips64) |
| 9 | */ |
| 10 | |
| 11 | /* Make sure include/asm-parisc/elf.h does the right thing */ |
| 12 | |
| 13 | #define ELF_CLASS ELFCLASS32 |
| 14 | |
| 15 | #define ELF_CORE_COPY_REGS(dst, pt) \ |
| 16 | memset(dst, 0, sizeof(dst)); /* don't leak any "random" bits */ \ |
| 17 | { int i; \ |
| 18 | for (i = 0; i < 32; i++) dst[i] = (elf_greg_t) pt->gr[i]; \ |
| 19 | for (i = 0; i < 8; i++) dst[32 + i] = (elf_greg_t) pt->sr[i]; \ |
| 20 | } \ |
| 21 | dst[40] = (elf_greg_t) pt->iaoq[0]; dst[41] = (elf_greg_t) pt->iaoq[1]; \ |
| 22 | dst[42] = (elf_greg_t) pt->iasq[0]; dst[43] = (elf_greg_t) pt->iasq[1]; \ |
| 23 | dst[44] = (elf_greg_t) pt->sar; dst[45] = (elf_greg_t) pt->iir; \ |
| 24 | dst[46] = (elf_greg_t) pt->isr; dst[47] = (elf_greg_t) pt->ior; \ |
| 25 | dst[48] = (elf_greg_t) mfctl(22); dst[49] = (elf_greg_t) mfctl(0); \ |
| 26 | dst[50] = (elf_greg_t) mfctl(24); dst[51] = (elf_greg_t) mfctl(25); \ |
| 27 | dst[52] = (elf_greg_t) mfctl(26); dst[53] = (elf_greg_t) mfctl(27); \ |
| 28 | dst[54] = (elf_greg_t) mfctl(28); dst[55] = (elf_greg_t) mfctl(29); \ |
| 29 | dst[56] = (elf_greg_t) mfctl(30); dst[57] = (elf_greg_t) mfctl(31); \ |
| 30 | dst[58] = (elf_greg_t) mfctl( 8); dst[59] = (elf_greg_t) mfctl( 9); \ |
| 31 | dst[60] = (elf_greg_t) mfctl(12); dst[61] = (elf_greg_t) mfctl(13); \ |
| 32 | dst[62] = (elf_greg_t) mfctl(10); dst[63] = (elf_greg_t) mfctl(15); |
| 33 | |
| 34 | |
| 35 | typedef unsigned int elf_greg_t; |
| 36 | |
| 37 | #include <linux/spinlock.h> |
| 38 | #include <asm/processor.h> |
| 39 | #include <linux/module.h> |
| 40 | #include <linux/elfcore.h> |
| 41 | #include <linux/compat.h> /* struct compat_timeval */ |
| 42 | |
| 43 | #define elf_prstatus elf_prstatus32 |
| 44 | struct elf_prstatus32 |
| 45 | { |
| 46 | struct elf_siginfo pr_info; /* Info associated with signal */ |
| 47 | short pr_cursig; /* Current signal */ |
| 48 | unsigned int pr_sigpend; /* Set of pending signals */ |
| 49 | unsigned int pr_sighold; /* Set of held signals */ |
| 50 | pid_t pr_pid; |
| 51 | pid_t pr_ppid; |
| 52 | pid_t pr_pgrp; |
| 53 | pid_t pr_sid; |
| 54 | struct compat_timeval pr_utime; /* User time */ |
| 55 | struct compat_timeval pr_stime; /* System time */ |
| 56 | struct compat_timeval pr_cutime; /* Cumulative user time */ |
| 57 | struct compat_timeval pr_cstime; /* Cumulative system time */ |
| 58 | elf_gregset_t pr_reg; /* GP registers */ |
| 59 | int pr_fpvalid; /* True if math co-processor being used. */ |
| 60 | }; |
| 61 | |
| 62 | #define elf_prpsinfo elf_prpsinfo32 |
| 63 | struct elf_prpsinfo32 |
| 64 | { |
| 65 | char pr_state; /* numeric process state */ |
| 66 | char pr_sname; /* char for pr_state */ |
| 67 | char pr_zomb; /* zombie */ |
| 68 | char pr_nice; /* nice val */ |
| 69 | unsigned int pr_flag; /* flags */ |
| 70 | u16 pr_uid; |
| 71 | u16 pr_gid; |
| 72 | pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid; |
| 73 | /* Lots missing */ |
| 74 | char pr_fname[16]; /* filename of executable */ |
| 75 | char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ |
| 76 | }; |
| 77 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | #define init_elf_binfmt init_elf32_binfmt |
| 79 | |
| 80 | #define ELF_PLATFORM ("PARISC32\0") |
| 81 | |
| 82 | /* |
| 83 | * We should probably use this macro to set a flag somewhere to indicate |
| 84 | * this is a 32 on 64 process. We could use PER_LINUX_32BIT, or we |
| 85 | * could set a processor dependent flag in the thread_struct. |
| 86 | */ |
| 87 | |
Helge Deller | cf8e18e | 2013-03-02 20:15:28 +0100 | [diff] [blame] | 88 | #undef SET_PERSONALITY |
Martin Schwidefsky | 0b59268 | 2008-10-16 15:39:57 +0200 | [diff] [blame] | 89 | #define SET_PERSONALITY(ex) \ |
Kyle McMartin | df570b9 | 2006-08-27 11:04:26 -0400 | [diff] [blame] | 90 | set_thread_flag(TIF_32BIT); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | current->thread.map_base = DEFAULT_MAP_BASE32; \ |
| 92 | current->thread.task_size = DEFAULT_TASK_SIZE32 \ |
| 93 | |
Frederic Weisbecker | cd19c36 | 2017-01-31 04:09:27 +0100 | [diff] [blame] | 94 | #undef ns_to_timeval |
| 95 | #define ns_to_timeval ns_to_compat_timeval |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | #include "../../../fs/binfmt_elf.c" |