Import 2.3.40pre5
[davej-history.git] / arch / sparc64 / kernel / binfmt_elf32.c
blob76516f2f246d99fdbc9515dd4f8a3c60ae7f3d95
1 /*
2 * binfmt_elf32.c: Support 32-bit Sparc ELF binaries on Ultra.
4 * Copyright (C) 1995, 1996, 1997, 1998 David S. Miller (davem@dm.cobaltmicro.com)
5 * Copyright (C) 1995, 1996, 1997, 1998 Jakub Jelinek (jj@ultra.linux.cz)
6 */
8 #define ELF_ARCH EM_SPARC
9 #define ELF_CLASS ELFCLASS32
10 #define ELF_DATA ELFDATA2MSB;
12 /* For the most part we present code dumps in the format
13 * Solaris does.
15 typedef unsigned int elf_greg_t;
16 #define ELF_NGREG 38
17 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
19 /* Format is:
20 * G0 --> G7
21 * O0 --> O7
22 * L0 --> L7
23 * I0 --> I7
24 * PSR, PC, nPC, Y, WIM, TBR
26 #include <asm/psrcompat.h>
27 #define ELF_CORE_COPY_REGS(__elf_regs, __pt_regs) \
28 do { unsigned int *dest = &(__elf_regs[0]); \
29 struct pt_regs *src = (__pt_regs); \
30 unsigned int *sp; \
31 int i; \
32 for(i = 0; i < 16; i++) \
33 dest[i] = (unsigned int) src->u_regs[i];\
34 /* Don't try this at home kids... */ \
35 set_fs(USER_DS); \
36 sp = (unsigned int *) (src->u_regs[14] & \
37 0x00000000fffffffc); \
38 for(i = 0; i < 16; i++) \
39 __get_user(dest[i+16], &sp[i]); \
40 set_fs(KERNEL_DS); \
41 dest[32] = tstate_to_psr(src->tstate); \
42 dest[33] = (unsigned int) src->tpc; \
43 dest[34] = (unsigned int) src->tnpc; \
44 dest[35] = src->y; \
45 dest[36] = dest[37] = 0; /* XXX */ \
46 } while(0);
48 typedef struct {
49 union {
50 unsigned int pr_regs[32];
51 unsigned long pr_dregs[16];
52 } pr_fr;
53 unsigned int __unused;
54 unsigned int pr_fsr;
55 unsigned char pr_qcnt;
56 unsigned char pr_q_entrysize;
57 unsigned char pr_en;
58 unsigned int pr_q[64];
59 } elf_fpregset_t;
61 /* UltraSparc extensions. Still unused, but will be eventually. */
62 typedef struct {
63 unsigned int pr_type;
64 unsigned int pr_align;
65 union {
66 struct {
67 union {
68 unsigned int pr_regs[32];
69 unsigned long pr_dregs[16];
70 long double pr_qregs[8];
71 } pr_xfr;
72 } pr_v8p;
73 unsigned int pr_xfsr;
74 unsigned int pr_fprs;
75 unsigned int pr_xg[8];
76 unsigned int pr_xo[8];
77 unsigned long pr_tstate;
78 unsigned int pr_filler[8];
79 } pr_un;
80 } elf_xregset_t;
82 #define elf_check_arch(x) (((x) == EM_SPARC) || ((x) == EM_SPARC32PLUS))
84 #define ELF_ET_DYN_BASE 0x08000000
87 #include <asm/processor.h>
88 #include <linux/module.h>
89 #include <linux/config.h>
90 #include <linux/elfcore.h>
92 struct timeval32
94 int tv_sec, tv_usec;
97 #define elf_prstatus elf_prstatus32
98 struct elf_prstatus32
100 struct elf_siginfo pr_info; /* Info associated with signal */
101 short pr_cursig; /* Current signal */
102 unsigned int pr_sigpend; /* Set of pending signals */
103 unsigned int pr_sighold; /* Set of held signals */
104 pid_t pr_pid;
105 pid_t pr_ppid;
106 pid_t pr_pgrp;
107 pid_t pr_sid;
108 struct timeval32 pr_utime; /* User time */
109 struct timeval32 pr_stime; /* System time */
110 struct timeval32 pr_cutime; /* Cumulative user time */
111 struct timeval32 pr_cstime; /* Cumulative system time */
112 elf_gregset_t pr_reg; /* GP registers */
113 int pr_fpvalid; /* True if math co-processor being used. */
116 #define elf_prpsinfo elf_prpsinfo32
117 struct elf_prpsinfo32
119 char pr_state; /* numeric process state */
120 char pr_sname; /* char for pr_state */
121 char pr_zomb; /* zombie */
122 char pr_nice; /* nice val */
123 unsigned int pr_flag; /* flags */
124 u16 pr_uid;
125 u16 pr_gid;
126 pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
127 /* Lots missing */
128 char pr_fname[16]; /* filename of executable */
129 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
132 #include <linux/highuid.h>
134 #undef NEW_TO_OLD_UID
135 #undef NEW_TO_OLD_GID
136 #define NEW_TO_OLD_UID(uid) ((uid) > 65535) ? (u16)overflowuid : (u16)(uid)
137 #define NEW_TO_OLD_GID(gid) ((gid) > 65535) ? (u16)overflowgid : (u16)(gid)
139 #define elf_addr_t u32
140 #define elf_caddr_t u32
141 #undef start_thread
142 #define start_thread start_thread32
143 #define init_elf_binfmt init_elf32_binfmt
144 #undef CONFIG_BINFMT_ELF
145 #ifdef CONFIG_BINFMT_ELF32
146 #define CONFIG_BINFMT_ELF CONFIG_BINFMT_ELF32
147 #endif
148 #undef CONFIG_BINFMT_ELF_MODULE
149 #ifdef CONFIG_BINFMT_ELF32_MODULE
150 #define CONFIG_BINFMT_ELF_MODULE CONFIG_BINFMT_ELF32_MODULE
151 #endif
152 #define ELF_FLAGS_INIT current->thread.flags |= SPARC_FLAG_32BIT
154 MODULE_DESCRIPTION("Binary format loader for compatibility with 32bit SparcLinux binaries on the Ultra");
155 MODULE_AUTHOR("Eric Youngdale, David S. Miller, Jakub Jelinek");
157 #undef MODULE_DESCRIPTION
158 #undef MODULE_AUTHOR
160 #include "../../../fs/binfmt_elf.c"